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

NullPointerException when jmockit and cucumber are used together #517

Closed
rnveach opened this issue May 3, 2018 · 3 comments
Closed

NullPointerException when jmockit and cucumber are used together #517

rnveach opened this issue May 3, 2018 · 3 comments
Assignees
Labels

Comments

@rnveach
Copy link

@rnveach rnveach commented May 3, 2018

  • Version of JMockit that was used: 1.39

  • Description of the problem:
    When running mvn test when the project contains cucumber and jmockit I get the following exception when the jmockit class runs before the cucumber test:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.407 sec <<< FAILURE!
Feature: Is it Friday yet?  Time elapsed: 0.397 sec  <<< ERROR!
java.lang.NullPointerException
	at java.lang.Class.isAssignableFrom(Native Method)
	at mockit.integration.junit4.internal.RunNotifierDecorator.fireTestStarted(RunNotifierDecorator.java:49)
	at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java)
	at cucumber.runtime.junit.JUnitReporter$EachTestNotifier.fireTestStarted(JUnitReporter.java:256)
	at cucumber.runtime.junit.JUnitReporter.handleTestCaseStarted(JUnitReporter.java:87)
	at cucumber.runtime.junit.JUnitReporter$1.receive(JUnitReporter.java:34)
	at cucumber.runtime.junit.JUnitReporter$1.receive(JUnitReporter.java:30)
	at cucumber.runner.EventBus.send(EventBus.java:28)
	at cucumber.api.TestCase.run(TestCase.java:55)
	at cucumber.runner.Runner.runPickle(Runner.java:80)
	at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:140)
	at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
	at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
	at cucumber.api.junit.Cucumber.runChild(Cucumber.java:118)
	at cucumber.api.junit.Cucumber.runChild(Cucumber.java:56)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:127)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Complete the 10 minute tutorial for cucumber at https://docs.cucumber.io/guides/10-minute-tutorial/ to create the base project.
Add the following dependency to the POM:

		<dependency>
			<groupId>org.jmockit</groupId>
			<artifactId>jmockit</artifactId>
			<version>1.39</version>
			<scope>test</scope>
		</dependency>

Add the following dummy test to the project:

package a;

import mockit.integration.junit4.JMockit;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(JMockit.class)
public class ATest {
	@Test
	public void test() {
	}
}

Issue occurs when mvn test is run and the ATest runs before the RunCucumberTest.
No exception results if the RunCucumberTest goes first.

@rliesenfeld

This comment has been minimized.

Copy link
Member

@rliesenfeld rliesenfeld commented May 11, 2018

More information (like, a minimal Cucumber-specific test file) would be needed to reproduce.

@rnveach

This comment has been minimized.

Copy link
Author

@rnveach rnveach commented May 11, 2018

@rliesenfeld

minimal Cucumber-specific test file

Completing the 10 minute tutorial from the link I provided does give you a cucumber test file.
After completing the steps you will have 1 feature file, 1 test file, and 1 step definition file.

You will also need to manually verify that the JMock test runs before the cucumber test.

@rnveach

This comment has been minimized.

Copy link
Author

@rnveach rnveach commented May 11, 2018

I zipped up my workspace and placed it at http://rveach.no-ip.org/cucumberWorkspace.zip .

@rliesenfeld rliesenfeld reopened this May 12, 2018
@rliesenfeld rliesenfeld self-assigned this May 12, 2018
@jmockit jmockit deleted a comment from rami-deltoro Jul 2, 2018
@jmockit jmockit locked and limited conversation to collaborators Jul 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.