Search in sources :

Example 6 with IDEATestNGRemoteListener

use of org.testng.IDEATestNGRemoteListener in project intellij-community by JetBrains.

the class TestNGTreeHierarchyTest method testParallelTestExecutionPreserveInvocationCount.

@Test
public void testParallelTestExecutionPreserveInvocationCount() throws Exception {
    final StringBuffer buf = new StringBuffer();
    final IDEATestNGRemoteListener listener = createListener(buf);
    listener.onStart((ISuite) null);
    final MockTestNGResult[] results = new MockTestNGResult[] { new MockTestNGResult("ATest", "testName"), new MockTestNGResult("ATest", "testName1"), new MockTestNGResult("ATest", "testName") };
    for (MockTestNGResult result : results) {
        listener.onTestStart(result);
        listener.onTestFinished(result);
    }
    listener.onFinish((ISuite) null);
    Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.testName' locationHint='java:test://ATest.testName|[0|]']\n" + "\n" + "##teamcity[testFinished name='ATest.testName']\n" + "\n" + "##teamcity[testStarted name='ATest.testName1' locationHint='java:test://ATest.testName1|[0|]']\n" + "\n" + "##teamcity[testFinished name='ATest.testName1']\n" + "\n" + "##teamcity[testStarted name='ATest.testName (1)' locationHint='java:test://ATest.testName|[1|]']\n" + "\n" + "##teamcity[testFinished name='ATest.testName (1)']\n" + "##teamcity[testSuiteFinished name='ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
Also used : IDEATestNGRemoteListener(org.testng.IDEATestNGRemoteListener) Test(org.junit.Test) XmlTest(org.testng.xml.XmlTest)

Example 7 with IDEATestNGRemoteListener

use of org.testng.IDEATestNGRemoteListener in project intellij-community by JetBrains.

the class TestNGTreeHierarchyTest method doTest.

private static void doTest(XmlSuite suite, String expected) {
    final StringBuffer buf = new StringBuffer();
    final IDEATestNGRemoteListener listener = createListener(buf);
    for (XmlTest test : suite.getTests()) {
        for (XmlClass aClass : test.getClasses()) {
            final String classFQName = aClass.getName();
            for (XmlInclude include : aClass.getIncludedMethods()) {
                final String methodName = include.getName();
                List<Integer> numbers = include.getInvocationNumbers();
                if (numbers.isEmpty()) {
                    numbers = Collections.singletonList(0);
                }
                for (Integer integer : numbers) {
                    final MockTestNGResult result = new MockTestNGResult(classFQName, methodName, null, new Object[] { integer });
                    listener.onTestStart(result);
                    listener.onTestFinished(result);
                }
            }
        }
    }
    Assert.assertEquals("output: " + buf, expected, StringUtil.convertLineSeparators(buf.toString()));
}
Also used : XmlInclude(org.testng.xml.XmlInclude) XmlTest(org.testng.xml.XmlTest) IDEATestNGRemoteListener(org.testng.IDEATestNGRemoteListener) XmlClass(org.testng.xml.XmlClass)

Example 8 with IDEATestNGRemoteListener

use of org.testng.IDEATestNGRemoteListener in project intellij-community by JetBrains.

the class TestNGTreeHierarchyTest method testConfigurationFailure.

@Test
public void testConfigurationFailure() throws Exception {
    final StringBuffer buf = new StringBuffer();
    final IDEATestNGRemoteListener listener = createListener(buf);
    final String className = "a.ATest";
    listener.onSuiteStart(className, true);
    final MockTestNGResult setUp = new MockTestNGResult(className, "setUp", createExceptionWithoutTrace(), ArrayUtil.EMPTY_OBJECT_ARRAY);
    listener.onConfigurationStart(setUp);
    listener.onConfigurationFailure(setUp);
    listener.onSuiteFinish(className);
    Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.setUp' locationHint='java:test://a.ATest.setUp' config='true']\n" + "\n" + "##teamcity[testFailed name='ATest.setUp' details='java.lang.Exception|n' error='true' message='']\n" + "\n" + "##teamcity[testFinished name='ATest.setUp']\n" + "##teamcity[testSuiteFinished name='a.ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
Also used : IDEATestNGRemoteListener(org.testng.IDEATestNGRemoteListener) Test(org.junit.Test) XmlTest(org.testng.xml.XmlTest)

Example 9 with IDEATestNGRemoteListener

use of org.testng.IDEATestNGRemoteListener in project intellij-community by JetBrains.

the class TestNGTreeHierarchyTest method testSkipTestMethod.

@Test
public void testSkipTestMethod() throws Exception {
    final StringBuffer buf = new StringBuffer();
    final IDEATestNGRemoteListener listener = createListener(buf);
    listener.onStart((ISuite) null);
    listener.onTestSkipped(new MockTestNGResult("ATest", "testName"));
    listener.onFinish((ISuite) null);
    Assert.assertEquals("output: " + buf, "##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://ATest']\n" + "\n" + "##teamcity[testStarted name='ATest.testName' locationHint='java:test://ATest.testName|[0|]']\n" + "\n" + "##teamcity[testIgnored name='ATest.testName']\n" + "\n" + "##teamcity[testFinished name='ATest.testName']\n" + "##teamcity[testSuiteFinished name='ATest']\n", StringUtil.convertLineSeparators(buf.toString()));
}
Also used : IDEATestNGRemoteListener(org.testng.IDEATestNGRemoteListener) Test(org.junit.Test) XmlTest(org.testng.xml.XmlTest)

Aggregations

IDEATestNGRemoteListener (org.testng.IDEATestNGRemoteListener)9 XmlTest (org.testng.xml.XmlTest)9 Test (org.junit.Test)8 XmlClass (org.testng.xml.XmlClass)1 XmlInclude (org.testng.xml.XmlInclude)1