Modify

Opened 5 years ago

Last modified 5 years ago

#17012 new defect

JMockit : Cannot execute JUnit test MultipolygonTest from Eclipse

Reported by: GerdP Owned by: team
Priority: normal Milestone:
Component: Unit tests Version:
Keywords: eclipse jmockit Cc: ris

Description

When I try to execute MultipolygonTestTest in Eclipse I see the dump below. What do I have to do to make this work again?

MultipolygonTestTest
org.openstreetmap.josm.data.validation.tests.MultipolygonTestTest
testTicket10469(org.openstreetmap.josm.data.validation.tests.MultipolygonTestTest)
java.lang.ExceptionInInitializerError
	at org.openstreetmap.josm.testutils.JOSMTestRules.before(JOSMTestRules.java:543)
	at org.openstreetmap.josm.testutils.JOSMTestRules$CreateJosmEnvironment.evaluate(JOSMTestRules.java:640)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	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 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.IllegalStateException: JMockit didn't get initialized; please check the -javaagent JVM initialization parameter was used
	at mockit.internal.startup.Startup.verifyInitialization(Startup.java:91)
	at mockit.MockUp.<clinit>(MockUp.java:56)

	... 19 more

Attachments (0)

Change History (8)

comment:1 by Don-vip, 5 years ago

Cc: ris added
Keywords: eclipse jmockit added

It's very cumbersome right now because JMockit requires adding VM argument -javaagent:<your directory>/josm/core/test/lib/jmockit-1.43.jar on the command line

comment:2 by Don-vip, 5 years ago

@ris can we make a change so this is only needed for tests really using JMockit? It shouldn't be needed for 90% of tests, like MultipolygonTestTest in this case.

comment:3 by michael2402, 5 years ago

We should add a new test rules setting for this - but this will only work on a per-class basis.

When we switch to Junit Jupiter, we can write an extension and add the @ExtendWith() only to the test methods that use it.

in reply to:  1 comment:4 by GerdP, 5 years ago

Replying to Don-vip:

It's very cumbersome right now because JMockit requires adding VM argument -javaagent:<your directory>/josm/core/test/lib/jmockit-1.43.jar on the command line

OK, that did the trick. Just a hint: This is not needed to run e.g. RelationCheckerTest.

comment:5 by ris, 5 years ago

can we make a change so this is only needed for tests really using JMockit?

That's a very good question - the answer is I don't know. I don't know a lot about eclipse and how it runs individual tests...

comment:6 by Don-vip, 5 years ago

This is not really specific to Eclipse, you may have the issue with all IDEs I think, as I don't see how they could guess we need to add the JMockit agent. How do you run unit tests while developing them?

comment:7 by ris, 5 years ago

I'm a text-editor-and-a-terminal kinda guy. If I want to run a subset or just a particular test I really just change the glob pattern in <batchtest><fileset> ... and re-run.

comment:8 by michael2402, 5 years ago

In #8269 there is a gradle build script.

Once we switch to gradle, you can simply use --tests=..pattern..

For Eclipse, you can use a new JVM configuration for your project. You can use the same Java home directory but you add the agent arguments to the default arguments. Since the tests in your project are then run using that JVM, you always have the agent even if you just re-run a single test.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to GerdP.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.