TestNG cannot find JUnit method names from Spock
See original GitHub issueThe Spock framework creates JUnit tests. These should be able to be run via TestNG. However, in the org.testng.junit.JUnit4TestMethod class there is this code:
private static Method getMethod(Description desc) {
Class<?> c = desc.getTestClass();
String method = desc.getMethodName();
try {
return c.getMethod(method);
} catch (Throwable t) {
Utils.log("JUnit4TestMethod", 2,
"Method '" + method + "' not found in class '" + c.getName() + "': " + t.getMessage());
return null;
}
}
Since the passed in description has the text of the Spock test (something like: “This is my spock test”) and Spock mangles the test names, the simple “c.getMethod(method)” call fails. If this is fixed, then TestNG should be able to run Spock (JUnit) tests as well.
Issue Analytics
- State:
- Created 9 years ago
- Comments:13
Top Results From Across the Web
Eclipse cannot find groovy class for Spock/Junit test
To do this, in the Package Explorer window, right click on the Project name, select "Build Path" from the menu, then select "Configure...
Read more >Problems using Spock and TestNG together - Google Groups
I want to be able to keep most existing tests, and use Spock/JUnit in parallel. TestNG has an option for that: junit="true" on...
Read more >TestNG | IntelliJ IDEA Documentation - JetBrains
To quickly navigate to a file, press Ctrl+Shift+N and enter its name. ... In the tool window that opens, type testNG in the...
Read more >Stubbing and Mocking in Java with the Spock Testing ...
Learn how to create true Java unit tests by mocking all external dependencies in your unit tests with the Spock testing framework.
Read more >Maven Surefire Plugin – surefire:test - Apache Maven
1 and JUnit 4.12, the @Category annotation type is automatically inherited from superclasses, see @java.lang.annotation.Inherited . Make sure ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rumatoest Instead of complaining you could spend your free time to debug/bugfix this. I’m sick of people thinking about usable tools/frameworks as always being baked by a huge company. TestNG is, as stated by @juherr, a spare-time project.
As I’m already wanted to get in touch with Spock (always eager to learn new stuff), I might take a look into this the next time.
Conceptually necessity of adding junit into my current project will lead me to use only junit in next projects.