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

Specify run order #2

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Specify run order #2

wants to merge 6 commits into from

Conversation

amamiya-yuuko-1225
Copy link
Owner

@amamiya-yuuko-1225 amamiya-yuuko-1225 commented Jul 27, 2022

This PR is a new implement for PR#348.

The changes in this pull request enable Surefire to run test classes and test methods in any order specified by a newly added <runOrder> (testorder). Namely, the changes include

  • A new <runOrder> called testorder that would make Surefire run test classes and test methods in the order specified by <test>. Regex and include/exclude are supported as is the case for other runOrders
  • Tests for the newly added features

The newly added testorder <runOrder> is supported for JUnit 3 and JUnit 4 tests.

Moreover, I have also implement a preliminary support for JUnit5, but I need some help to make it better. For this reason, I created another PR to show that change. Looking forward to discuss it with you developers about this issue.

Simple (no regex) example using Http-Request:

mvn test -Dsurefire.runOrder=testorder \
-Dtest=com.github.kevinsawicki.http.HttpRequestTest#getUrlEncodedWithPercent,\
com.github.kevinsawicki.http.HttpRequestTest#uploadProgressSendReader,\
com.github.kevinsawicki.http.HttpRequestTest#malformedStringUrlCause,\
com.github.kevinsawicki.http.EncodeTest#encode

Output from Maven should say that the test class HttpRequestTest ran before EncodeTest

The file HttpRequestTest.xml (http-request/lib/target/surefire-reports/TEST-com.github.kevinsawicki.http.HttpRequestTest.xml) should say

<testcase name="getUrlEncodedWithPercent"...>
<testcase name="uploadProgressSendReader"...>
<testcase name="malformedStringUrlCause...>

Regex example using Http-Request:

mvn test -Dsurefire.runOrder=testorder \
-Dtest=com.github.kevinsawicki.http.EncodeTest*,\
com.github.kevinsawicki.http.HttpRequestTest#getUrl*

Output from Maven should say

Tests run: 2 … in 
com.github.kevinsawicki.http.EncodeTest
Tests run: 4 … in
com.github.kevinsawicki.http.HttpRequestTest

The file HttpRequestTest.xml (http-request/lib/target/surefire-reports/TEST-com.github.kevinsawicki.http.HttpRequestTest.xml) should say

<testcase name=”getUrlEncodedWithPercent”...>
<testcase name="getUrlEncodedWithSpace"...>
<testcase name="getUrlEncodedWithUnicode”...>
<testcase name="getUrlEmpty”...>

Include/Exclude example using Http-Request:

mvn test -Dsurefire.runOrder=testorder \
-Dtest=com.github.kevinsawicki.http.HttpRequestTest#getUrl*,\
\!com.github.kevinsawicki.http.HttpRequestTest#getUrlEmpty

Output from Maven should say
Tests run: 3 … in

com.github.kevinsawicki.http.HttpRequestTest

The file HttpRequestTest.xml (http-request/lib/target/surefire-reports/TEST-com.github.kevinsawicki.http.HttpRequestTest.xml) should say

<testcase name=”getUrlEncodedWithPercent”...>
<testcase name="getUrlEncodedWithSpace"...>
<testcase name="getUrlEncodedWithUnicode”...>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant