Search in sources :

Example 56 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class JMeterReporterTest method testPrintJMeterReport.

@Test(dataProvider = "counts")
public void testPrintJMeterReport(int total, int failures) {
    String expectedOutput = String.format("Transactions executed: %d, failed: %d", total, failures);
    JMeterTransactions transactions = mock(JMeterTransactions.class);
    when(transactions.getTransactionCount()).thenReturn(total);
    when(transactions.getFailCount()).thenReturn(failures);
    String output = new JMeterReporter(transactions).getJMeterReport();
    assertThat(output, containsString(expectedOutput));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 57 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class PassedTransactionsTestTest method verifyExecuteMethodPass.

@Test
public void verifyExecuteMethodPass() {
    PassedTransactionsTest test = new PassedTransactionsTest("Test #1", "passedTransactionsTest", "Verify number of passed tests", "Login", 0);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.LOGIN_1000_SUCCESS);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.PASS)));
    assertThat(test.getActualResultDescription(), containsString("Number of failed transactions = 0"));
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 58 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class PassedTransactionsTestTest method testPrintTestExecutionReportIgnored.

@Test
public void testPrintTestExecutionReportIgnored() {
    String expectedOutput = String.format("Test name:            Test #1%n" + "Test type:            passedTransactionsTest%n" + "Test description:     Verify number of passed tests%n" + "Transaction name:     incorrect%n" + "Expected result:      Number of failed transactions <= 0%n" + "Actual result:        No transactions with label equal to 'incorrect' found in CSV file%n" + "Transaction count:    0%n" + "Test result:          ERROR");
    PassedTransactionsTest test = new PassedTransactionsTest("Test #1", "passedTransactionsTest", "Verify number of passed tests", "incorrect", 0);
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.LOGIN_1000_SUCCESS);
    test.execute(jmeterTransactions);
    String output = test.getTestExecutionReport();
    assertThat(output, containsString(expectedOutput));
}
Also used : JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 59 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class TestSetTest method verifyExecuteClientMethod_1_1_1.

@Test
public void verifyExecuteClientMethod_1_1_1() {
    RespTimeAvgTest respTimeAvgTestA = new RespTimeAvgTest("Test #1", "avgRespTimeTest", "", "Login", 4000);
    RespTimeAvgTest respTimeAvgTestB = new RespTimeAvgTest("Test #2", "avgRespTimeTest", "", "Search", 5000);
    RespTimeAvgTest respTimeAvgTestC = new RespTimeAvgTest("Test #3", "avgRespTimeTest", "", "Sear", 1000);
    JMeterTransactions transactions = new JMeterTransactions();
    transactions.add(TestData.LOGIN_3514_SUCCESS);
    transactions.add(TestData.SEARCH_11221_SUCCESS);
    List<ClientSideTest> tests = new ArrayList<>();
    tests.add(respTimeAvgTestA);
    tests.add(respTimeAvgTestB);
    tests.add(respTimeAvgTestC);
    TestSet testSet = new TestSet(tests, null);
    configureStream();
    testSet.executeClientSideTests(transactions);
    revertStream();
    assertThat(testSet.getTestCount(), is(3));
    assertThat(testSet.getPassCount(), is(1));
    assertThat(testSet.getFailCount(), is(1));
    assertThat(testSet.getErrorCount(), is(1));
}
Also used : ClientSideTest(uk.co.automatictester.lightning.tests.ClientSideTest) RespTimeAvgTest(uk.co.automatictester.lightning.tests.RespTimeAvgTest) ArrayList(java.util.ArrayList) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) RespTimeAvgTest(uk.co.automatictester.lightning.tests.RespTimeAvgTest) Test(org.testng.annotations.Test) PassedTransactionsTest(uk.co.automatictester.lightning.tests.PassedTransactionsTest) ServerSideTest(uk.co.automatictester.lightning.tests.ServerSideTest) ClientSideTest(uk.co.automatictester.lightning.tests.ClientSideTest)

Example 60 with JMeterTransactions

use of uk.co.automatictester.lightning.data.JMeterTransactions in project lightning by automatictester.

the class TestSetTest method verifyExecuteClientMethod_2_0_0.

@Test
public void verifyExecuteClientMethod_2_0_0() {
    PassedTransactionsTest passedTransactionsTestA = new PassedTransactionsTest("Test #1", "passedTransactionsTest", "Verify number of passed tests", "Login", 0);
    PassedTransactionsTest passedTransactionsTestB = new PassedTransactionsTest("Test #2", "passedTransactionsTest", "Verify number of passed tests", null, 0);
    JMeterTransactions transactions = new JMeterTransactions();
    transactions.add(TestData.LOGIN_3514_SUCCESS);
    transactions.add(TestData.SEARCH_11221_SUCCESS);
    List<ClientSideTest> tests = new ArrayList<>();
    tests.add(passedTransactionsTestA);
    tests.add(passedTransactionsTestB);
    TestSet testSet = new TestSet(tests, null);
    configureStream();
    testSet.executeClientSideTests(transactions);
    revertStream();
    assertThat(testSet.getTestCount(), is(2));
    assertThat(testSet.getPassCount(), is(2));
    assertThat(testSet.getFailCount(), is(0));
    assertThat(testSet.getErrorCount(), is(0));
}
Also used : ClientSideTest(uk.co.automatictester.lightning.tests.ClientSideTest) ArrayList(java.util.ArrayList) PassedTransactionsTest(uk.co.automatictester.lightning.tests.PassedTransactionsTest) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) RespTimeAvgTest(uk.co.automatictester.lightning.tests.RespTimeAvgTest) Test(org.testng.annotations.Test) PassedTransactionsTest(uk.co.automatictester.lightning.tests.PassedTransactionsTest) ServerSideTest(uk.co.automatictester.lightning.tests.ServerSideTest) ClientSideTest(uk.co.automatictester.lightning.tests.ClientSideTest)

Aggregations

JMeterTransactions (uk.co.automatictester.lightning.data.JMeterTransactions)67 Test (org.testng.annotations.Test)58 DescriptiveStatistics (org.apache.commons.math3.stat.descriptive.DescriptiveStatistics)5 ClientSideTest (uk.co.automatictester.lightning.tests.ClientSideTest)5 PassedTransactionsTest (uk.co.automatictester.lightning.tests.PassedTransactionsTest)5 ServerSideTest (uk.co.automatictester.lightning.tests.ServerSideTest)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CSVFileIOException (uk.co.automatictester.lightning.exceptions.CSVFileIOException)2 CSVFileNoTransactionsException (uk.co.automatictester.lightning.exceptions.CSVFileNoTransactionsException)2 RespTimeAvgTest (uk.co.automatictester.lightning.tests.RespTimeAvgTest)2 Percent (uk.co.automatictester.lightning.utils.Percent)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1 Percentile (org.apache.commons.math3.stat.descriptive.rank.Percentile)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 IntToOrdConverter (uk.co.automatictester.lightning.utils.IntToOrdConverter)1