TestNG, JMockit and listeners... Follow
Hi,
I am probably missing something fundamental here, but here goes...
We are using TestNG and JMockit. JMockit needs some "funky" initialization, giving this error, if not done:
java.lang.IllegalStateException: JMockit wasn't properly initialized; check that jmockit.jar precedes junit.jar in the classpath (if using JUnit; if not, check the documentation)
at mockit.internal.expectations.RecordAndReplayExecution.validateRecordingContext(RecordAndReplayExecution.java:60)
at mockit.internal.expectations.RecordAndReplayExecution.<init>(RecordAndReplayExecution.java:91)
at mockit.Expectations.<init>(Expectations.java:135)
at mockit.NonStrictExpectations.<init>(NonStrictExpectations.java:28)
at
In ant, its working fine, as I specify the jmockit listener on the testng task, like so:
<testng listeners="mockit.integration.testng.Initializer">...
In IDEA, I can add the listener to the tests in the "edit configurations" / Configuration / Listeners tab.
But I need to remember this for each test.
I see there is a TestNG defaults section, but it does not allow me to add a "default" listener.
I looked at the testng.xml file, and I could set the listener there, but I don't think that helps me with IDEA, if I want to just right click and run one of my tests, I don't think it will be used.
Is there a way to setup a default listener?
Or perhaps a better/alternative way to configure IDEA/TestNG/JMockit.
Thanks in advance for any tips/advice.
Chris
Please sign in to leave a comment.
Chris, why can't you setup default listener? Do you have multiple modules and IDEA states that listenr can't be chosen without a module selected? Thanks
Hi Anna,
It complains that I can't browse listeners as "module is not selected" - I only have one and I tried selecting it on the first (JDK settings/classpath) tab, but perhaps that is the wrong place to select it...
Thanks,
Chris
Chris, that is the correct place. Somehow it works only after apply. So please try now - choose module, ok to close dialog. Then invoke edit default configuration and choose corresponding listener.
Should be fixed ASAP.
Thank you for notification
Hi Anna,
Doh - I should have tried that.
Will try tomorrow, when I am back in the office.
Thanks,
Chris
That seems to have worked - although it took 2 goes, I went in and made the module the default, hit apply and then went to the listeners tab, clicked Add but then cancelled it as I didnt know the name. IDEA then decided it wasnt happy and I had to kill the app :(
After starting it up, its now taken it.
I dont suppose this change is saved in the project file - guess its a global config setting...
Thanks,
Chris