[testng-dev] failures reported as errors in junitreport

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[testng-dev] failures reported as errors in junitreport

Thorson Little
See attached environment

This may be a misunderstanding on my part

Occurs using both eclipse plugin and ant task

To repro:
Testclass:

package com.example.pkg;

import static org.testng.Assert.*;
import org.testng.annotations.Test:

public class JunitExample {
  @Test
  public void firstTest() {
 assertTrue( true, "This assertion and test passes" );
  }
  
  @Test
  public void secondTest() {
 assertTrue( true, "Assertion 1/3 passes" );
 assertTrue(true);
 assertTrue( false, "Assertion 3/3 fails and whole test fails");
  }
  
  @Test 
  public void thirdTest() {
 assertTrue( true, "true assertion" );
 
 fail( "This is a failure" );
  }
  
}


Results:

TEST-com.example.pkg.JunitExample.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by org.testng.reporters.JUnitReportReporter -->
<testsuite hostname="tlittle-lt" name="com.example.pkg.JunitExample" tests="3" failures="0" timestamp="22 Mar 2013 16:25:33 GMT" time="0.007" errors="2">
  <testcase name="thirdTest" time="0.000" classname="com.example.pkg.JunitExample">
    <error type="java.lang.AssertionError" message="This is a failure">
      <![CDATA[java.lang.AssertionError: This is a failure
at org.testng.Assert.fail(Assert.java:94)
at com.example.pkg.JunitExample.thirdTest(JunitExample.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at org.testng.TestNG.privateMain(TestNG.java:1338)
at org.testng.TestNG.main(TestNG.java:1307)
]]>
    </error>
  </testcase> <!-- thirdTest -->
  <testcase name="firstTest" time="0.006" classname="com.example.pkg.JunitExample"/>
  <testcase name="secondTest" time="0.001" classname="com.example.pkg.JunitExample">
    <error type="java.lang.AssertionError" message="Assertion 3/3 fails and whole test fails expected [true] but found [false]">
      <![CDATA[java.lang.AssertionError: Assertion 3/3 fails and whole test fails expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:494)
...
at org.testng.TestNG.main(TestNG.java:1307)
]]>
    </error>
  </testcase> <!-- secondTest -->
</testsuite> <!-- com.example.pkg.JunitExample -->


Expected Results:

I expect assertion failures to report as failures and not errors here:
<testsuite hostname="tlittle-lt" name="com.example.pkg.JunitExample" tests="3" failures="0" timestamp="22 Mar 2013 16:25:33 GMT" time="0.007" errors="2">

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

playSpace.zip (93K) Download Attachment