create suitetest in jenkins
source:https://github.com/fhoeben/hsac-fitnesse-fixtures
- we start the tomcat instance for jenkins by executing the tomcat jenkins - start.cmd script
- open a browser and navigate to: http://localhost:8075/jenkins/
- click in the sidemenu on New Job
- for this exercise, we are using the account status webservice
- call this item: wsaccountstatus_suitetest
- select the first radiobutton create a freestyle project
- in the Source Code Management section select the Git radiobutton
- enter the url: https://bitbucket.org/johantuitel/easywebservices.git
- select the credentials you have made for your bitbucket account
- in my case it was j.tuitel@developers.nl/*(bitbucket account)
- after that we need to set the correct branch in the field Branches to build
- enter: develop
- add a build step and select Invoke Top-level Maven
- target: clean test-compile failsafe:integration-test -Pfitnesse-integration
- POM: AccountStatusWebservice\fitnesse\pom.xml
- navigate to the Post-build Actions and add Publish HTML reports
- click on the Add button
- HTML directory to archive: AccountStatusWebservice\fitnesse\target\fitnesse-results
- Index page
- Report title: Fitnesse Report
- click on Save and we are done
test job
- click on building the job
- click on the Fitnesse Report link
- but hey, there are no result!
- this is because the smoketest is executed and not the suite
- this is correct because we did not configured the suite to run and we need this to be configured
add string parameters in the jobs
- navigate to the smoketest jenkins job: http://localhost:8075/jenkins/job/ws_account_status_smoketest/
- click on the Configure link
- click the checkbox This build is parameterized
add a String Paramater
- Name: SUITETORUN
- Default Value: FitNesse.UserGuide.TwoMinuteExample
navigate to the suitetest jenkins job: http://localhost:8075/jenkins/job/ws_account_status_suitetest/
- click on the Configure link
- click the checkbox This build is parameterized
- add a String Parameter
- Name: SUITETORUN
- Default Value: FitNesse.SuiteAcceptanceTests.SuiteSlimTests
when done you can build the project with parameters
pass test when building the job
- navigate to the Build section
- add this to the target -DfitnesseSuiteToRun=${SUITETORUN}
setup maven fitnesse-integration profile to use a custom test
- add a
<fitnesseSuiteToRun>${fitnesseSuiteToRun}</fitnesseSuiteToRun>
as a
<systemPropertyVariables>
create a custom FitnesseRunner class to get the fitnesseSuiteToRun property
- create a package nl.com.devnl.junit
create a java class called DemoFitnesseRunner.java and extend it from the FitnesseRunner.java
extends from FitNesseRunner
override the getSuiteName method
package nl.com.devnl.junit;
import fitnesse.junit.FitNesseRunner;
import org.junit.runners.model.InitializationError;
public class DemoFitnesseRunner extends FitNesseRunner{
public DemoFitnesseRunner(Class<?> suiteClass) throws org.junit.runners.model.InitializationError {
super(suiteClass);
}
@Override
protected String getSuiteName(Class<?> klass) throws InitializationError {
String suiteName = System.getProperty("fitnesseSuiteToRun");
if(null == suiteName || "".equals(suiteName)){
Suite suiteAnnotation = klass.getAnnotation(Suite.class);
if (suiteAnnotation == null) {
throw new InitializationError("There must be a @Suite annotation");
}else{
suiteName = suiteAnnotation.value();
}
}
return suiteName;
}
}
- set the DemoFitnesseRunner in the FitnesseTest class
package nl.com.devnl.fitnesse;
import nl.com.devnl.junit.DemoFitnesseRunner;
import org.junit.runner.RunWith;
@RunWith(DemoFitnesseRunner.class)
@DemoFitnesseRunner.Suite("FitNesse.UserGuide.TwoMinuteExample")
@DemoFitnesseRunner.FitnesseDir("../fitnesse")
@DemoFitnesseRunner.OutputDir("target/fitnesse-results")
public class FitnesseTest {
}
test the parameterized job
- when navigating to http://localhost:8075/jenkins/job/ws_account_status_smoketest/ you can click on Build with Parameters
- you now see a parameter to set
- click on build
note: by setting the SUITETORUN, the suite test is executed after the smoketest!