Skip to content
Permalink
Browse files
[FIXED JENKINS-13821] Replaced TestNG classes by testng-parser, and f…
…ixed the data providers behaviour.
  • Loading branch information
kinow committed Apr 17, 2013
1 parent 4e84c34 commit 69ea27429dcb0c280b04c033de38d2595fb819d5
Showing 17 changed files with 88 additions and 1,274 deletions.
@@ -284,7 +284,12 @@
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>com.tupilabs</groupId>
<artifactId>testng-parser</artifactId>
<version>0.2</version>
</dependency>
</dependencies>

<repositories>
<repository>
@@ -24,6 +24,9 @@
package hudson.plugins.testlink;

import hudson.CopyOnWrite;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import hudson.model.Items;
import hudson.model.AbstractProject;
import hudson.model.Descriptor;
import hudson.model.FreeStyleProject;
@@ -45,6 +48,9 @@
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.TestNGParser;

/**
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 1.0
@@ -156,4 +162,15 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return Boolean.TRUE;
}

@Initializer(before=InitMilestone.PLUGINS_STARTED)
public static void addAliases() {
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.Suite", Suite.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.TestNGParser", TestNGParser.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.Test", com.tupilabs.testng.parser.Test.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.TestMethod", com.tupilabs.testng.parser.TestMethod.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.Class", com.tupilabs.testng.parser.Class.class);
Items.XSTREAM2.addCompatibilityAlias("hudson.plugins.testlink.testng.ParserException", com.tupilabs.testng.parser.ParserException.class);
Items.XSTREAM2.alias("hudson.plugins.testlink.testng.Class.list", java.util.LinkedList.class, java.util.LinkedHashSet.class);
}

}
@@ -28,8 +28,6 @@
import hudson.model.Result;
import hudson.model.AbstractBuild;
import hudson.plugins.testlink.TestLinkSite;
import hudson.plugins.testlink.testng.Suite;
import hudson.plugins.testlink.testng.TestNGParser;
import hudson.remoting.VirtualChannel;

import java.io.File;
@@ -39,6 +37,9 @@
import br.eti.kinoshita.testlinkjavaapi.model.Attachment;
import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.TestNGParser;

/**
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 3.1
@@ -29,10 +29,6 @@
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.plugins.testlink.TestLinkSite;
import hudson.plugins.testlink.testng.Class;
import hudson.plugins.testlink.testng.Suite;
import hudson.plugins.testlink.testng.Test;
import hudson.plugins.testlink.testng.TestMethod;
import hudson.plugins.testlink.util.Messages;
import hudson.remoting.VirtualChannel;

@@ -46,6 +42,10 @@

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;

/**
* <p>Seeks for test results matching each TestNG Class name with the key
* custom field.</p>
@@ -110,7 +110,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)
});
for(Suite suite : suites) {
for(Test test : suite.getTests() ) {
for(hudson.plugins.testlink.testng.Class clazz : test.getClasses()) {
for(com.tupilabs.testng.parser.Class clazz : test.getClasses()) {
for(TestCaseWrapper automatedTestCase : automatedTestCases) {
final String[] commaSeparatedValues = automatedTestCase.getKeyCustomFieldValues(this.keyCustomField);
for(String value : commaSeparatedValues) {
@@ -152,7 +152,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)
* @param suite
* @return
*/
private ExecutionStatus getExecutionStatus(hudson.plugins.testlink.testng.Class clazz) {
private ExecutionStatus getExecutionStatus(com.tupilabs.testng.parser.Class clazz) {
for( TestMethod method : clazz.getTestMethods() ) {
if ( StringUtils.isNotBlank(method.getStatus()) ) {
if(method.getStatus().equals(FAIL)) {
@@ -176,8 +176,7 @@ private ExecutionStatus getExecutionStatus(hudson.plugins.testlink.testng.Class
* @param clazz TestNG test class.
* @return notes for TestNG suite and test class.
*/
private String getTestNGNotes( Suite suite, Class clazz )
{
private String getTestNGNotes(Suite suite, com.tupilabs.testng.parser.Class clazz) {
StringBuilder notes = new StringBuilder();

notes.append(
@@ -29,10 +29,6 @@
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.plugins.testlink.TestLinkSite;
import hudson.plugins.testlink.testng.Suite;
import hudson.plugins.testlink.testng.Test;
import hudson.plugins.testlink.testng.TestMethod;
import hudson.plugins.testlink.testng.TestNGParser;
import hudson.plugins.testlink.util.Messages;
import hudson.remoting.VirtualChannel;

@@ -46,6 +42,11 @@

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;
import com.tupilabs.testng.parser.TestNGParser;

/**
* <p>Seeks for test results matching each TestNG Method name and its Data
* Provider name with key custom fields.</p>
@@ -127,23 +128,23 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)
return suites;
}
});
for(Suite suite : suites) {
for(Test test : suite.getTests() ) {
for(hudson.plugins.testlink.testng.Class clazz : test.getClasses()) {
for(TestMethod method : clazz.getTestMethods()) {
for(TestCaseWrapper automatedTestCase : automatedTestCases) {
for (Suite suite : suites) {
for (Test test : suite.getTests()) {
for (com.tupilabs.testng.parser.Class clazz : test.getClasses()) {
for (TestMethod method : clazz.getTestMethods()) {
for (TestCaseWrapper automatedTestCase : automatedTestCases) {
final String qualifiedName = clazz.getName()+'#'+method.getName();
final String dataProviderName = method.getDataProvider();
final String[] commaSeparatedValues = automatedTestCase.getKeyCustomFieldValues(this.keyCustomField);
final String dataProviderValue = automatedTestCase.getKeyCustomFieldValue(this.dataProviderNameKeyCustomField);
for(String value : commaSeparatedValues) {
if(qualifiedName.equals(value) && dataProviderName.equals(dataProviderValue)) {
for (String value : commaSeparatedValues) {
if (qualifiedName.equals(value) && dataProviderName.equals(dataProviderValue)) {
ExecutionStatus status = this.getExecutionStatus(method);
if(status != ExecutionStatus.NOT_RUN) {
if (status != ExecutionStatus.NOT_RUN) {
automatedTestCase.addCustomFieldAndStatus(value, status);
}

if(this.isIncludeNotes()) {
if (this.isIncludeNotes()) {
final String notes = this.getTestNGNotes(method);
automatedTestCase.appendNotes(notes);
}
@@ -29,10 +29,6 @@
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.plugins.testlink.TestLinkSite;
import hudson.plugins.testlink.testng.Suite;
import hudson.plugins.testlink.testng.Test;
import hudson.plugins.testlink.testng.TestMethod;
import hudson.plugins.testlink.testng.TestNGParser;
import hudson.plugins.testlink.util.Messages;
import hudson.remoting.VirtualChannel;

@@ -46,6 +42,11 @@

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;
import com.tupilabs.testng.parser.TestNGParser;

/**
* <p>Seeks for test results matching each TestNG Method name with the key
* custom field.</p>
@@ -112,7 +113,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)
});
for(Suite suite : suites) {
for(Test test : suite.getTests() ) {
for(hudson.plugins.testlink.testng.Class clazz : test.getClasses()) {
for(com.tupilabs.testng.parser.Class clazz : test.getClasses()) {
for(TestMethod method : clazz.getTestMethods()) {
for(TestCaseWrapper automatedTestCase : automatedTestCases) {
final String qualifiedName = clazz.getName()+'#'+method.getName();
@@ -29,10 +29,6 @@
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.plugins.testlink.TestLinkSite;
import hudson.plugins.testlink.testng.Suite;
import hudson.plugins.testlink.testng.Test;
import hudson.plugins.testlink.testng.TestMethod;
import hudson.plugins.testlink.testng.TestNGParser;
import hudson.plugins.testlink.util.Messages;
import hudson.remoting.VirtualChannel;

@@ -45,6 +41,11 @@

import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;

import com.tupilabs.testng.parser.Suite;
import com.tupilabs.testng.parser.Test;
import com.tupilabs.testng.parser.TestMethod;
import com.tupilabs.testng.parser.TestNGParser;

/**
* <p>Seeks for test results matching each TestNG Suite name with the key
* custom field.</p>
@@ -142,7 +143,7 @@ public List<Suite> invoke(File workspace, VirtualChannel channel)
*/
private ExecutionStatus getExecutionStatus(Suite suite) {
for( Test test : suite.getTests() ) {
for( hudson.plugins.testlink.testng.Class clazz : test.getClasses() ) {
for(com.tupilabs.testng.parser.Class clazz : test.getClasses()) {
for( TestMethod method : clazz.getTestMethods() ) {
if(method.getStatus().equals(FAIL)) {
return ExecutionStatus.FAILED;

This file was deleted.

0 comments on commit 69ea274

Please sign in to comment.