public class TestLinkXmlRunListener extends AbstractTestLinkRunListener<net.oneandone.testlinkjunit.tljunit.InTestLinkXmlRunListener>
You have to configure the surefire plugin to use the additional TestLinkXmlRunListener
.
As can be seen below, the tester name and file-location for the result file may be provided as system properties.
The resulting XML is written as UTF-8.
<properties> <tljunit.version>X.X<tljunit.version> </properties> [...] <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.10</version> <dependencies> <dependency> <groupId>net.oneandone.testlinkjunit</groupId> <artifactId>tljunit-surefire</artifactId> <version>
${tljunit.version}</version> </dependency> </dependencies> <configuration> <properties> <property> <name>listener</name> <value>net.oneandone.testlinkjunit.tljunit.TestLinkXmlRunListener</value> </property> </properties> <systemPropertyVariables> <testlink.results>target/my-testlink.xml</testlink.results> <testlink.tester>memyselfandi</testlink.tester> </systemPropertyVariables> </configuration> </plugin> [...] <dependencies> <dependency> <groupId>net.oneandone.testlinkjunit</groupId> <artifactId>tljunit</artifactId> <version>
${tljunit.version}</version> </dependency> </dependencies> [...]
Now running mvn test will run your tests and put the resulting TestLink XML file into target/my-testlink.xml using memyselfandi as name of the user who executed the test run.
public static void main(String[] args) throws FileNotFoundException { final JUnitCore core = new JUnitCore(); core.addListener(new TestLinkXmlRunListener(System.out, "name_of_tester")); core.run(MyTest.class); }
Note that this implementation is threadsafe but holds all results in memory before flushing them to the specified XML file.
Constructor and Description |
---|
TestLinkXmlRunListener()
Instantiates
TestLinkXmlRunListener(OutputStream, String) with parameters taken
from System properties. |
TestLinkXmlRunListener(OutputStream out,
String tester)
Writes results to out using tester as name of the tester.
|
Modifier and Type | Method and Description |
---|---|
void |
testRunFinished(Result result)
Will write the result to the outputstream and close the stream afterwards.
|
getInTestLinkListener, testAssumptionFailure, testFailure, testFinished, testIgnored, testStarted
testRunStarted
public TestLinkXmlRunListener() throws FileNotFoundException
TestLinkXmlRunListener(OutputStream, String)
with parameters taken
from System properties.
testlink.results
testlink.tester
FileNotFoundException
- when the file could not be written, e.g. the parent directory does not exist.public TestLinkXmlRunListener(OutputStream out, String tester)
testRunFinished(org.junit.runner.Result)
,
out will be closed there.out
- the xml data is written to.tester
- name of the tester.public void testRunFinished(Result result) throws Exception
testRunFinished
in class RunListener
Exception
Copyright © 2012–2013 1&1. All rights reserved.