Sunday 15 January 2012

java - TestNG skipping Tests when a Test can't be instantiated -



java - TestNG skipping Tests when a Test can't be instantiated -

i understand testng has configfailurepolicy flag go on tests when there error in @before method. there way go on running remaining tests when 1 test got errored out.. exception during test class instantiation?

is possible study error , fail build?

here test classes.

public class mytest { public mytest() { throw new runtimeexception(); } @test public void testmethod1() { ... } @test public void testmethod2() { ... } } public class mytest2 { @test public void testmethod1() { ... } @test public void testmethod2() { ... } }

now, running these tests via maven:

mvn clean test

output:

running test suite .... cause by: org.testng.testngexception cannot instantiate class ...mytest1 .... cause by: java.lang.runtimeexception: .... results: tests run: 0, failed: 0, errors: 0, skipped: 0 .... -------------- build success -------------- total time: ..

maven pom:

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>...</groupid> <artifactid>...</artifactid> <version>1.0.0-snapshot</version> <packaging>war</packaging> <name>xyz</name> <dependencies> .... <dependency> <groupid>org.testng</groupid> <artifactid>testng</artifactid> <version>6.1.1</version> </dependency> </dependencies> <build> <plugins> .... <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.9</version> </plugin> </plugins> </build> <reporting> <outputdirectory>${basedir}/target/site</outputdirectory> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-report-plugin</artifactid> <version>2.4.1</version> </plugin> </plugins> </reporting> </project>

java maven testng

No comments:

Post a Comment