Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding platform management #8

Merged
merged 1 commit into from
Sep 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/hudson/plugins/testlink/AbstractTestLinkBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public class AbstractTestLinkBuilder extends Builder {
/**
* The name of the Build.
*/
protected final String platformName;
/**
* The platform name.
*/
protected String buildName;

/**
Expand Down Expand Up @@ -171,6 +175,7 @@ public AbstractTestLinkBuilder(
String testLinkName,
String testProjectName,
String testPlanName,
String platformName,
String buildName,
String customFields,
Boolean executionStatusNotRun,
Expand All @@ -190,6 +195,7 @@ public AbstractTestLinkBuilder(
this.testLinkName = testLinkName;
this.testProjectName = testProjectName;
this.testPlanName = testPlanName;
this.platformName = platformName;
this.buildName = buildName;
this.customFields = customFields;
this.executionStatusNotRun = executionStatusNotRun;
Expand Down Expand Up @@ -229,6 +235,7 @@ public AbstractTestLinkBuilder(
String testLinkName,
String testProjectName,
String testPlanName,
String platformName,
String buildName,
String customFields,
Boolean executionStatusNotRun,
Expand All @@ -249,6 +256,7 @@ public AbstractTestLinkBuilder(
this.testLinkName = testLinkName;
this.testProjectName = testProjectName;
this.testPlanName = testPlanName;
this.platformName = platformName;
this.buildName = buildName;
this.customFields = customFields;
this.executionStatusNotRun = executionStatusNotRun;
Expand Down Expand Up @@ -295,6 +303,11 @@ public String getTestPlanName()
return this.testPlanName;
}

public String getPlatformName()
{
return this.platformName;
}

public String getBuildName()
{
return this.buildName;
Expand Down
29 changes: 22 additions & 7 deletions src/main/java/hudson/plugins/testlink/TestLinkBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import br.eti.kinoshita.testlinkjavaapi.TestLinkAPI;
import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionStatus;
import br.eti.kinoshita.testlinkjavaapi.model.Build;
import br.eti.kinoshita.testlinkjavaapi.model.Platform;
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
import br.eti.kinoshita.testlinkjavaapi.model.TestPlan;
import br.eti.kinoshita.testlinkjavaapi.model.TestProject;
Expand All @@ -80,7 +81,7 @@ public class TestLinkBuilder extends AbstractTestLinkBuilder {
* @deprecated
*/
public TestLinkBuilder(String testLinkName, String testProjectName,
String testPlanName, String buildName, String customFields,
String testPlanName, String platformName, String buildName, String customFields,
Boolean executionStatusNotRun, Boolean executionStatusPassed,
Boolean executionStatusFailed, Boolean executionStatusBlocked,
List<BuildStep> singleBuildSteps,
Expand All @@ -89,7 +90,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName,
List<BuildStep> afterIteratingAllTestCasesBuildSteps,
Boolean transactional, Boolean failedTestsMarkBuildAsFailure,
Boolean failIfNoResults, List<ResultSeeker> resultSeekers) {
super(testLinkName, testProjectName, testPlanName, buildName,
super(testLinkName, testProjectName, testPlanName, platformName, buildName,
customFields, executionStatusNotRun, executionStatusPassed,
executionStatusFailed, executionStatusBlocked, singleBuildSteps,
beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps,
Expand All @@ -99,7 +100,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName,

@DataBoundConstructor
public TestLinkBuilder(String testLinkName, String testProjectName,
String testPlanName, String buildName, String customFields,
String testPlanName, String platformName, String buildName, String customFields,
Boolean executionStatusNotRun, Boolean executionStatusPassed,
Boolean executionStatusFailed, Boolean executionStatusBlocked,
List<BuildStep> singleBuildSteps,
Expand All @@ -108,7 +109,7 @@ public TestLinkBuilder(String testLinkName, String testProjectName,
List<BuildStep> afterIteratingAllTestCasesBuildSteps,
Boolean transactional, Boolean failedTestsMarkBuildAsFailure,
Boolean failIfNoResults, Boolean failOnNotRun, List<ResultSeeker> resultSeekers) {
super(testLinkName, testProjectName, testPlanName, buildName,
super(testLinkName, testProjectName, testPlanName, platformName, buildName,
customFields, executionStatusNotRun, executionStatusPassed,
executionStatusFailed, executionStatusBlocked, singleBuildSteps,
beforeIteratingAllTestCasesBuildSteps, iterativeBuildSteps,
Expand Down Expand Up @@ -148,6 +149,8 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
build.getEnvironment(listener), getTestProjectName());
final String testPlanName = expandVariable(build.getBuildVariableResolver(),
build.getEnvironment(listener), getTestPlanName());
final String platformName = expandVariable(build.getBuildVariableResolver(),
build.getEnvironment(listener), getPlatformName());
final String buildName = expandVariable(build.getBuildVariableResolver(),
build.getEnvironment(listener), getBuildName());
final String buildNotes = Messages.TestLinkBuilder_Build_Notes();
Expand All @@ -158,7 +161,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
LOGGER.log(Level.FINE, "TestLink build notes: ["+buildNotes+"]");
}
// TestLink Site object
testLinkSite = this.getTestLinkSite(testLinkUrl, testLinkDevKey, testProjectName, testPlanName, buildName, buildNotes);
testLinkSite = this.getTestLinkSite(testLinkUrl, testLinkDevKey, testProjectName, testPlanName, platformName, buildName, buildNotes);
final String[] customFieldsNames = this.createArrayOfCustomFieldsNames(build.getBuildVariableResolver(), build.getEnvironment(listener));
final Set<ExecutionStatus> executionStatuses = this.getExecutionStatuses();
// Array of automated test cases
Expand Down Expand Up @@ -273,7 +276,7 @@ private TestCaseWrapper[] transform(TestCase[] testCases) {
*/
public TestLinkSite getTestLinkSite(String testLinkUrl,
String testLinkDevKey, String testProjectName, String testPlanName,
String buildName, String buildNotes) throws MalformedURLException {
String platformName, String buildName, String buildNotes) throws MalformedURLException {
final TestLinkAPI api;
final URL url = new URL(testLinkUrl);
api = new TestLinkAPI(url, testLinkDevKey);
Expand All @@ -283,11 +286,23 @@ public TestLinkSite getTestLinkSite(String testLinkUrl,

final TestPlan testPlan = api.getTestPlanByName(testPlanName,
testProjectName);

Platform p = null;
if (!platformName.equals("")){
Platform platforms[] = api.getProjectPlatforms(testProject.getId());
for (int i = 0; i < platforms.length; i++) {
if (platforms[i].getName().equals(platformName)) {
p = platforms[i];
break;
}
}
}
final Platform platform = p;

final Build build = api.createBuild(testPlan.getId(), buildName,
buildNotes);

return new TestLinkSite(api, testProject, testPlan, build);
return new TestLinkSite(api, testProject, testPlan, platform, build);
}

/**
Expand Down
40 changes: 35 additions & 5 deletions src/main/java/hudson/plugins/testlink/TestLinkSite.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
import br.eti.kinoshita.testlinkjavaapi.model.TestPlan;
import br.eti.kinoshita.testlinkjavaapi.model.TestProject;
import br.eti.kinoshita.testlinkjavaapi.model.Platform;

/**
* Immutable object that represents the TestLink site with a Test Project,
Expand All @@ -54,6 +55,7 @@ public class TestLinkSite
protected final TestLinkAPI api;
protected final TestProject testProject;
protected final TestPlan testPlan;
protected final Platform platform;
protected final Build build;
protected final Report report;

Expand All @@ -63,12 +65,13 @@ public class TestLinkSite
* @param testPlan TestLink Test Plan
* @param build TestLink Build
*/
public TestLinkSite(TestLinkAPI api, TestProject testProject, TestPlan testPlan, Build build)
public TestLinkSite(TestLinkAPI api, TestProject testProject, TestPlan testPlan, Platform platform, Build build)
{
super();
this.api = api;
this.testProject = testProject;
this.testPlan = testPlan;
this.platform = platform;
this.build = build;
if(build != null)
{
Expand Down Expand Up @@ -101,7 +104,15 @@ public TestPlan getTestPlan()
{
return testPlan;
}


/**
* @return the platform
*/
public Platform getPlatform()
{
return platform;
}

/**
* @return the build
*/
Expand Down Expand Up @@ -185,7 +196,25 @@ public int updateTestCase(TestCaseWrapper testCase) {
&& !ExecutionStatus.NOT_RUN.equals(testCase
.getExecutionStatus())) {
// Update Test Case status
final ReportTCResultResponse reportTCResultResponse = api.reportTCResult(
ReportTCResultResponse reportTCResultResponse = null;
if (platform != null){
reportTCResultResponse = api.reportTCResult(
testCase.getId(),
testCase.getInternalId(),
testPlan.getId(),
testCase.getExecutionStatus(),
build.getId(),
build.getName(),
testCase.getNotes(),
null, // guess
null, // bug id
platform.getId(),
platform.getName(),
null, // custom fields
null);
}
else {
reportTCResultResponse = api.reportTCResult(
testCase.getId(),
testCase.getInternalId(),
testPlan.getId(),
Expand All @@ -195,10 +224,11 @@ public int updateTestCase(TestCaseWrapper testCase) {
testCase.getNotes(),
null, // guess
null, // bug id
null, // platform id
testCase.getPlatform(), // platform name
null,
null, // platform name
null, // custom fields
null);
}

switch(testCase.getExecutionStatus()) {
case PASSED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<f:textbox name="TestLinkBuilder.testPlanName" value="${instance.testPlanName}"
checkUrl="'${rootURL}/builder/TestLinkBuilder/checkMandatory?value='+escape(this.value)"/>
</f:entry>

<f:entry title="${%Platform Name}" help="${rootURL}/../plugin/testlink/help-platformName.html">
<f:textbox name="TestLinkBuilder.platformName" value="${instance.platformName}"/>
</f:entry>

<f:entry title="${%Build Name}" help="${rootURL}/../plugin/testlink/help-buildName.html">
<f:textbox name="TestLinkBuilder.buildName" value="${instance.buildName}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Test\Link\ Version=TestLink Version
Test\ Project\ Name=Test Project Name
Test\ Plan\ Name=Test Plan Name
Platform\ Name=Platform Name
Build\ Name=Build Name
Custom\ Fields=Custom Fields
Key\ Custom\ Field=Key Custom Field
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Test\Link\ Version=Versi�n del TestLink
Test\ Project\ Name=Nombre del Proyecto de Pruebas
Test\ Plan\ Name=Nombre del Plan de Pruebas
Platform\ Name=Nombre de la Plataforma
Build\ Name=Nombre del Build
Custom\ Fields=Campos personalizados
Key\ Custom\ Field=Campo customizado chave para testes automatizados do TestLink
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Test\Link\ Version=Vers�o do TestLink
Test\ Project\ Name=Nome do Projeto de Testes
Test\ Plan\ Name=Nome do Plano de Testes
Platform\ Name=Nome da Plataforma
Build\ Name=Nome do Build
Custom\ Fields=Campos customizados
Key\ Custom\ Field=Campo customizado chave para testes automatizados do TestLink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class TestLinkSiteFake extends TestLinkSite {
protected List<TestCaseWrapper> testCases = new LinkedList<TestCaseWrapper>();

public TestLinkSiteFake() {
super(null, null, null, new Build(1, 1, "Fake build", "Fake notes"));
super(null, null, null, null, new Build(1, 1, "Fake build", "Fake notes"));
}

/* (non-Javadoc)
Expand Down
23 changes: 15 additions & 8 deletions src/test/java/hudson/plugins/testlink/TestTestLinkBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void setUp()
"No testlink",
"No project",
"No plan",
"No platform",
"No build",
"class, time, sample-job-$BUILD_ID",
Boolean.FALSE,
Expand Down Expand Up @@ -103,7 +104,7 @@ public void testListOfCustomFields()

public void testNull()
{
builder = new TestLinkBuilder(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
builder = new TestLinkBuilder(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);

assertNotNull( builder );

Expand All @@ -113,6 +114,8 @@ public void testNull()

assertNull( builder.getTestPlanName() );

assertNull( builder.getPlatformName() );

assertNull( builder.getBuildName() );

assertNull( builder.getSingleBuildSteps() );
Expand Down Expand Up @@ -147,6 +150,7 @@ public void testGetters()
"No testlink",
"No project",
"No plan",
"No platform",
"No build",
"class, time",
Boolean.FALSE,
Expand Down Expand Up @@ -176,6 +180,9 @@ public void testGetters()
assertNotNull( builder.getTestPlanName() );
assertEquals( builder.getTestPlanName(), "No plan" );

assertNotNull( builder.getPlatformName() );
assertEquals( builder.getPlatformName(), "No platform" );

assertNotNull( builder.getBuildName() );
assertEquals( builder.getBuildName(), "No build" );

Expand All @@ -194,7 +201,7 @@ public void testGetters()

@Test
public void getExecutionStatusesShouldReturnAllWhenAllAreFalse() {
builder = new TestLinkBuilder(null, null, null, null, null, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, null, null, null, null, null, null, null, null, null );
builder = new TestLinkBuilder(null, null, null, null, null, null, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, null, null, null, null, null, null, null, null, null );
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(4));
assertThat(
Expand All @@ -205,7 +212,7 @@ public void getExecutionStatusesShouldReturnAllWhenAllAreFalse() {

@Test
public void getExecutionStatusesShouldReturnAllWhenAllAreNull() {
builder = new TestLinkBuilder(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null );
builder = new TestLinkBuilder(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null );
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(4));
assertThat(
Expand All @@ -216,7 +223,7 @@ public void getExecutionStatusesShouldReturnAllWhenAllAreNull() {

@Test
public void getExecutionStatusesShouldReturnSomeWhenSomeAreTrue() {
builder = new TestLinkBuilder(null, null, null, null, null, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
builder = new TestLinkBuilder(null, null, null, null, null, null, Boolean.TRUE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(2));
assertThat(
Expand All @@ -226,7 +233,7 @@ public void getExecutionStatusesShouldReturnSomeWhenSomeAreTrue() {

@Test
public void getExecutionStatusesShouldOneSomeWhenNotRunIsTrue() {
builder = new TestLinkBuilder(null, null, null, null, null, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
builder = new TestLinkBuilder(null, null, null, null, null, null, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(1));
assertThat(
Expand All @@ -236,7 +243,7 @@ public void getExecutionStatusesShouldOneSomeWhenNotRunIsTrue() {

@Test
public void getExecutionStatusesShouldOneSomeWhenPassedIsTrue() {
builder = new TestLinkBuilder(null, null, null, null, null, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
builder = new TestLinkBuilder(null, null, null, null, null, null, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(1));
assertThat(
Expand All @@ -246,7 +253,7 @@ public void getExecutionStatusesShouldOneSomeWhenPassedIsTrue() {

@Test
public void getExecutionStatusesShouldOneSomeWhenFailedIsTrue() {
builder = new TestLinkBuilder(null, null, null, null, null, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
builder = new TestLinkBuilder(null, null, null, null, null, null, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, null, null, null, null, null, null, null, null, null);
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(1));
assertThat(
Expand All @@ -256,7 +263,7 @@ public void getExecutionStatusesShouldOneSomeWhenFailedIsTrue() {

@Test
public void getExecutionStatusesShouldOneSomeWhenBlockedIsTrue() {
builder = new TestLinkBuilder(null, null, null, null, null, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, null, null, null, null, null, null, null, null, null);
builder = new TestLinkBuilder(null, null, null, null, null, null, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, null, null, null, null, null, null, null, null, null);
Set<ExecutionStatus> statuses = builder.getExecutionStatuses();
assertThat(statuses, hasSize(1));
assertThat(
Expand Down