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

TestNG cannot find JUnit method names from Spock #506

Closed
blackduck-joe opened this issue Apr 1, 2014 · 13 comments
Closed

TestNG cannot find JUnit method names from Spock #506

blackduck-joe opened this issue Apr 1, 2014 · 13 comments

Comments

@blackduck-joe
Copy link

blackduck-joe commented Apr 1, 2014

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

@pniederw
Copy link

pniederw commented Apr 2, 2014

I wonder why TestNG is trying to get the Method for the test. This will cause troubles with quite a few testing frameworks implementing a JUnit runner.

@ArturGajowy
Copy link

+1

4 similar comments
@vivekchauhan
Copy link

+1

@ashishkrsahu
Copy link

+1

@bbooth
Copy link

bbooth commented Jan 27, 2015

+1

@BearSmash
Copy link

+1

@rumatoest
Copy link

+1

@blackduck-joe
Copy link
Author

This ticket is now 2+ years old. It still doesn't even have anyone (EVER) assigned! What a complete joke. If anyone is even considering use of TestNG you should be aware of the extremely poor support to expect. I only wish all of our tests were in JUnit...

@juherr
Copy link
Member

juherr commented May 27, 2016

We are supporting testng during our free time and we fixed other most important issues.

But the project is open, why not trying to fix it by yourself ? We'll love to help you to make a pull-request.

At the end, and as you said, JUnit is a solution too (and a good project).

@juherr
Copy link
Member

juherr commented May 28, 2016

Related to spockframework/spock#389 and spockframework/spock#385

@juherr
Copy link
Member

juherr commented May 28, 2016

@blackduck-joe I had a look on the issue and I've no idea how to fix it.

But your need is clearer in your SO thead, and if I understand it well you want to run 2 kind of tests (spock/junit and testng).
Then, if you are using maven, you should have a look on https://groups.google.com/forum/#!topic/spockframework/-iys4ARQrxk and/or Running TestNG and JUnit Tests

@rumatoest
Copy link

Conceptually necessity of adding junit into my current project will lead me to use only junit in next projects.

@FibreFoX
Copy link

FibreFoX commented Jun 3, 2016

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

@cbeust cbeust closed this as completed in aa8cc53 Jun 11, 2016
cbeust added a commit that referenced this issue Jun 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants