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

Consider adding a -n (no execute) option #1503

Closed
7 tasks
sharimo1 opened this issue Aug 17, 2017 · 7 comments · Fixed by #1658
Closed
7 tasks

Consider adding a -n (no execute) option #1503

sharimo1 opened this issue Aug 17, 2017 · 7 comments · Fixed by #1658
Assignees

Comments

@sharimo1
Copy link

TestNG Version

Note: only the latest version is supported

Expected behavior

I guess this is a feature request rather than a bug, but I saw in the testng-users questions that other people have this issue too. Please consider adding a no-execute option - one that will list the tests that will execute in the order they would execute without actually executing them.
This could be useful in cases such as:

  • When you have used "dependsOnMethods" to sequence tests
  • When you have used include/exclude in the testng.xml file
  • when you want see what tests have been tagged with a particular group name
  • To see the effects of combinations of the above!

Actual behavior

Is the issue reproductible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

Please, share the test case (as small as possible) which shows the issue

@juherr
Copy link
Member

juherr commented Aug 19, 2017

Thanks for the idea.

According to your idea, is the no-execute option supposed to execute (or not) factories and data providers?
Execution of both may have side effects in the system under test but we need them in order to find all test methods.

@tjni
Copy link

tjni commented Aug 19, 2017

In systems I've seen, this behavior is usually called a dry run, so, if implemented, I'd like to see the option name be closer to that.

My two cents: If all I'm told is the name of this feature, I would expect it to run everything except for the logic in the tests themselves. That is, tests would be the only side effects that are ignored.

@sharimo1
Copy link
Author

This is not an original idea. "make" which is the mother of all build tools had such an option:
https://www.gnu.org/software/make/manual/html_node/Options-Summary.html
Side effects may be necessary.
It would be nice to if a verbose option let me see what triggers a particular test to be included/excluded.

@cbeust
Copy link
Collaborator

cbeust commented Aug 21, 2017

I'm actually surprised it's not already there, I thought I had implemented that, but maybe I got myself confused with Kobalt, which allows that.

Since both Kobalt and TestNG use the same engine (DynamicGraph), this is actually pretty easy to implement: when comes the time to add the tasks to the graph, just return a Result object directly instead of calling the test method: example.

@krmahadevan
Copy link
Member

Inputs from @cbeust

FYI, it would be pretty easy to implement -dryRun:

  • Create a subclass of IWorker which, instead of actually running a test, immediately returns with a success status
  • Return these workers from the IWorkerFactory.

@krmahadevan krmahadevan self-assigned this Nov 30, 2017
@cbeust
Copy link
Collaborator

cbeust commented Nov 30, 2017

FYI, I used this exact same idea in Kobalt, which also uses DynamicGraph: link.

krmahadevan added a commit to krmahadevan/testng that referenced this issue Dec 29, 2017
Closes testng-team#1503

Users can now run their tests in a dry run mode 
by passing the JVM argument : testng.mode.dryrun=true
krmahadevan added a commit to krmahadevan/testng that referenced this issue Dec 29, 2017
Closes testng-team#1503

Users can now run their tests in a dry run mode 
by passing the JVM argument : testng.mode.dryrun=true
krmahadevan added a commit to krmahadevan/testng that referenced this issue Dec 29, 2017
Closes testng-team#1503

Users can now run their tests in a dry run mode 
by passing the JVM argument : testng.mode.dryrun=true
krmahadevan added a commit to krmahadevan/testng that referenced this issue Dec 30, 2017
Closes testng-team#1503

Users can now run their tests in a dry run mode 
by passing the JVM argument : testng.mode.dryrun=true
@krmahadevan
Copy link
Member

@sharimo1 - This is now available in TestNG 6.14-SNAPSHOT.

To run tests in dry mode, please use the JVM argument -Dtestng.mode.dryrun=true. When run in the dry run mode, TestNG will skip executing any of the @Test methods and also any of the @BeforeXXX/@AfterXXX configuration methods and instead fake them to have passed. But your data provider implementations, listener implementations etc., will still be executed.

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

Successfully merging a pull request may close this issue.

5 participants