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

isTestMethod in TestSuite does not recognize @Test annotation #1139

Closed
tkohegyi opened this issue May 8, 2015 · 2 comments
Closed

isTestMethod in TestSuite does not recognize @Test annotation #1139

tkohegyi opened this issue May 8, 2015 · 2 comments

Comments

@tkohegyi
Copy link

tkohegyi commented May 8, 2015

right now (v4.12) the isTestMethod method of TestSuite class ignores the methods those annotated with @test, and only accepts a method as test method is it starts with "test".

Suggest to fix it in the following way:

private boolean isTestMethod(Method m) {
        boolean isTestAnnotated = m.isAnnotationPresent(org.junit.Test.class);
        return m.getParameterTypes().length == 0 &&
                (m.getName().startsWith("test") || isTestAnnotated) &&
                m.getReturnType().equals(Void.TYPE);
    }
@kcooney
Copy link
Member

kcooney commented May 8, 2015

TestSuite is for legacy tests that don't use JUnit annotations. If your test classes use @Test then your test classes should not extend junit.framework.TestCase directly or indirectly.

In general, your classes should either import classes from org.junit or junit.framework but not both.

@tkohegyi
Copy link
Author

ok, thx, closing

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

No branches or pull requests

2 participants