CD part XIX: Create Suitetest

  • 17/03/2017
  • 3 minuten leestijd

CD part XIX: Create Suitetest

The smoketest is configured, so now we will be configuring the suitetest for complete testing of our application.

create suitetest in jenkins

source:https://github.com/fhoeben/hsac-fitnesse-fixtures

  1. we start the tomcat instance for jenkins by executing the tomcat jenkins - start.cmd script
  2. open a browser and navigate to: http://localhost:8075/jenkins/
  3. click in the sidemenu on New Job
  4. for this exercise, we are using the account status webservice
  5. call this item: wsaccountstatus_suitetest
  6. select the first radiobutton create a freestyle project
  7. in the Source Code Management section select the Git radiobutton
  8. enter the url: https://bitbucket.org/johantuitel/easywebservices.git
  9. select the credentials you have made for your bitbucket account
  10. in my case it was j.tuitel@developers.nl/*(bitbucket account) git credentials
  11. after that we need to set the correct branch in the field Branches to build
  12. enter: develop
  13. add a build step and select Invoke Top-level Maven
  14. target: clean test-compile failsafe:integration-test -Pfitnesse-integration
  15. POM: AccountStatusWebservice\fitnesse\pom.xml
  16. navigate to the Post-build Actions and add Publish HTML reports
  17. click on the Add button
    1. HTML directory to archive: AccountStatusWebservice\fitnesse\target\fitnesse-results
    2. Index page
    3. Report title: Fitnesse Report
  18. click on Save and we are done

test job

  1. click on building the job
  2. click on the Fitnesse Report link

fitnesse report

  1. but hey, there are no result!
  2. this is because the smoketest is executed and not the suite

fitnesse results

  1. 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

  1. navigate to the smoketest jenkins job: http://localhost:8075/jenkins/job/ws_account_status_smoketest/
  2. click on the Configure link
  3. click the checkbox This build is parameterized
  4. add a String Paramater

    1. Name: SUITETORUN
    2. Default Value: FitNesse.UserGuide.TwoMinuteExample
  5. navigate to the suitetest jenkins job: http://localhost:8075/jenkins/job/ws_account_status_suitetest/

  6. click on the Configure link
  7. click the checkbox This build is parameterized
  8. add a String Parameter
    1. Name: SUITETORUN
    2. Default Value: FitNesse.SuiteAcceptanceTests.SuiteSlimTests

when done you can build the project with parameters

build with parameters

pass test when building the job

  1. navigate to the Build section
  2. add this to the target -DfitnesseSuiteToRun=${SUITETORUN}

setup maven fitnesse-integration profile to use a custom test

  1. add a
<fitnesseSuiteToRun>${fitnesseSuiteToRun}</fitnesseSuiteToRun>

as a

<systemPropertyVariables>

add fitnesse suite to run parameter

create a custom FitnesseRunner class to get the fitnesseSuiteToRun property

  1. create a package nl.com.devnl.junit
  2. create a java class called DemoFitnesseRunner.java and extend it from the FitnesseRunner.java custom fitnesse runner structure

  3. extends from FitNesseRunner

  4. 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;
      }
    }
  1. 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

  1. when navigating to http://localhost:8075/jenkins/job/ws_account_status_smoketest/ you can click on Build with Parameters
  2. you now see a parameter to set

build with parameters

  1. click on build

note: by setting the SUITETORUN, the suite test is executed after the smoketest!