Search in sources :

Example 1 with Percent

use of uk.co.automatictester.lightning.utils.Percent in project lightning by automatictester.

the class LightningXMLFileReader method addPassedTransactionsTestNodes.

protected void addPassedTransactionsTestNodes(Document xmlDoc) {
    String testType = "passedTransactionsTest";
    NodeList passedTransactionsTestNodes = xmlDoc.getElementsByTagName(testType);
    for (int i = 0; i < passedTransactionsTestNodes.getLength(); i++) {
        Element passedTransactionsElement = (Element) passedTransactionsTestNodes.item(i);
        String name = getTestName(passedTransactionsElement);
        String description = getTestDescription(passedTransactionsElement);
        String transactionName = getTransactionName(passedTransactionsElement);
        int allowedNumberOfFailedTransactions;
        int allowedPercentOfFailedTransactions;
        PassedTransactionsTest passedTransactionsTest;
        if (isSubElementPresent(passedTransactionsElement, "allowedNumberOfFailedTransactions")) {
            allowedNumberOfFailedTransactions = getIntegerValueFromElement(passedTransactionsElement, "allowedNumberOfFailedTransactions");
            passedTransactionsTest = new PassedTransactionsTest(name, testType, description, transactionName, allowedNumberOfFailedTransactions);
        } else {
            allowedPercentOfFailedTransactions = getPercent(passedTransactionsElement, "allowedPercentOfFailedTransactions");
            passedTransactionsTest = new PassedTransactionsTest(name, testType, description, transactionName, new Percent(allowedPercentOfFailedTransactions));
        }
        passedTransactionsTest.setRegexp(isSubElementPresent(passedTransactionsElement, "regexp"));
        clientSideTests.add(passedTransactionsTest);
    }
}
Also used : Percent(uk.co.automatictester.lightning.utils.Percent) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element)

Example 2 with Percent

use of uk.co.automatictester.lightning.utils.Percent in project lightning by automatictester.

the class PassedTransactionsTestTest method verifyExecuteMethodPercentFail.

@Test
public void verifyExecuteMethodPercentFail() {
    PassedTransactionsTest test = new PassedTransactionsTest("Test #1", "passedTransactionsTest", "Verify percent of passed tests", "Search", new Percent(9));
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.SEARCH_1_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_2_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_3_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_4_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_5_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_6_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_7_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_8_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_9_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_800_FAILURE);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.FAIL)));
    assertThat(test.getActualResultDescription(), containsString("Percent of failed transactions = 10"));
}
Also used : Percent(uk.co.automatictester.lightning.utils.Percent) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Example 3 with Percent

use of uk.co.automatictester.lightning.utils.Percent in project lightning by automatictester.

the class LightningXMLFileReaderTest method verifyGetTestsMethodPassedPercentTest.

@Test
public void verifyGetTestsMethodPassedPercentTest() {
    LightningXMLFileReader xmlFileReader = new LightningXMLFileReader();
    xmlFileReader.readTests(TEST_SET_PASSED_PERCENT);
    List<ClientSideTest> tests = xmlFileReader.getClientSideTests();
    PassedTransactionsTest test = new PassedTransactionsTest("Test #3", "passedTransactionsTest", "Verify percent of passed tests", "Login", new Percent(0));
    assertThat(tests, hasSize(1));
    assertThat(tests.contains(test), is(true));
}
Also used : Percent(uk.co.automatictester.lightning.utils.Percent) Test(org.testng.annotations.Test)

Example 4 with Percent

use of uk.co.automatictester.lightning.utils.Percent in project lightning by automatictester.

the class PassedTransactionsTestTest method verifyExecuteMethodPercentPass.

@Test
public void verifyExecuteMethodPercentPass() {
    PassedTransactionsTest test = new PassedTransactionsTest("Test #1", "passedTransactionsTest", "Verify percent of passed tests", "Search", new Percent(10));
    JMeterTransactions jmeterTransactions = new JMeterTransactions();
    jmeterTransactions.add(TestData.SEARCH_1_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_2_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_3_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_4_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_5_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_6_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_7_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_8_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_9_SUCCESS);
    jmeterTransactions.add(TestData.SEARCH_800_FAILURE);
    test.execute(jmeterTransactions);
    assertThat(test.getResult(), is(equalTo(TestResult.PASS)));
    assertThat(test.getActualResultDescription(), containsString("Percent of failed transactions = 10"));
}
Also used : Percent(uk.co.automatictester.lightning.utils.Percent) JMeterTransactions(uk.co.automatictester.lightning.data.JMeterTransactions) Test(org.testng.annotations.Test)

Aggregations

Percent (uk.co.automatictester.lightning.utils.Percent)4 Test (org.testng.annotations.Test)3 JMeterTransactions (uk.co.automatictester.lightning.data.JMeterTransactions)2 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1