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

Error:Classes annotated with @RunWith(Cucumber.class) must not define any methods. #1

Closed
belgoros opened this issue Nov 22, 2011 · 6 comments

Comments

@belgoros
Copy link

cucumber.runtime.CucumberException: 

Classes annotated with @RunWith(Cucumber.class) must not define any methods.
Their sole purpose is to serve as an entry point for JUnit.
Step Definitions should be defined in their own classes.
This allows them to be reused across features.
Offending class: class net.ludeke.example.ATMTest

    at cucumber.junit.Cucumber.assertNoDeclaredMethods(Cucumber.java:67)
    at cucumber.junit.Cucumber.<init>(Cucumber.java:60)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I think you should declare steps in separate classes and not in the same one where you declare a feature.

@aluedeke
Copy link
Owner

fixed

@belgoros
Copy link
Author

Not at all, you didn't get me. You should extract all the methods from the test class annotated with '@RunWith(Cucumber.class) into a separate class to define the steps . Just try to run

mvn test

from the root of your project and you will see it your self:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running net.ludeke.example.ATMTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.182 sec <<< FAILURE!

Results :

Tests in error:
  initializationError(net.ludeke.example.ATMTest):

Classes annotated with @RunWith(Cucumber.class) must not define any methods.
Their sole purpose is to serve as an entry point for JUnit.
Step Definitions should be defined in their own classes.
This allows them to be reused across features.
Offending class: class net.ludeke.example.ATMTest


Tests run: 1, Failures: 0, Errors: 1, Skipped: 0


[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.726s
[INFO] Finished at: Tue Nov 22 16:29:42 CET 2011
[INFO] Final Memory: 4M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project cucum
ber-jvm-example: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Documents and Settings\A187589\Mes documents\ror\aluedeke-cucumber-jvm-example\target\surefir
e-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
C:\Documents and Settings\A187589\Mes documents\ror\aluedeke-cucumber-jvm-example>

@aluedeke
Copy link
Owner

All methods are now moved to ATMScenrio, that should be sufficient
On Tue, Nov 22, 2011 at 4:32 PM, Serguei Cambour <
reply@reply.github.com

wrote:

ATMTest

@belgoros
Copy link
Author

It's up to you, try to run Maven as mvn test and you will see the failure your self.

@aluedeke
Copy link
Owner

Hey,

done :-) "mvn test" works fine on the current master. May be you need to
check whether you have the latest version? I have updated the master 20-30
minutes after you posted the issue.

Kind Regards

Andreas

On Tue, Nov 22, 2011 at 4:43 PM, Serguei Cambour <
reply@reply.github.com

wrote:

It's up to you, try to run Maven as mvn test and you will see the failure
your self.


Reply to this email directly or view it on GitHub:

#1 (comment)

@belgoros
Copy link
Author

Greate, it works, thansk you.

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