Jahz
Jahz

Reputation: 29

Run a single JUnit test suite using Maven with Bitbucket pipeline

what should be done to have Bitbucket pipeline run a single specified JUnit test suite at the Maven verify step ?

With the template proposed by Atlassian here:

image: maven:3.3.9
pipelines:
  default:
    - step:
        script:
          - mvn -B verify    # -B batch mode makes Maven less verbose

Then Maven will run any test and test suite found, so tests are basically run twice (once as part of the suite, and once for themselves), inducing longer pipeline duration and reporting inaccuracies.

Upvotes: 1

Views: 1832

Answers (1)

Jahz
Jahz

Reputation: 29

Ok finally found it:

pipelines:
  default:
    - step:
        caches:
          - maven
        script:
          - mvn -B -Dtest=TestAll verify

This way only the TestAll test suite will be run, so all JUnit tests part of the suite will be run only once, and the ones not included (for instance tests waiting for a fix) will not (and the pipeline will stay succesful even with failing tests in the repo).

Upvotes: 1

Related Questions