jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
461 stars 239 forks source link

Issue with @Tested #183

Closed AmrutaM closed 9 years ago

AmrutaM commented 9 years ago

I am trying to use @Tested If i try to use the object reference which is marked as @Tested in method annotated with @Before that throws null pointer exception. but if i use that object reference directly with test method that just works fine. Below is the example:

@Tested private A a;

@Before public void doSetUp(){

a.setTest(); ---- this will throw NPE with version 1.17 and below }

But if i use the same piece of code in a test method like below:

@Test public void aTest(){

a.setTest(); -- This will just work fine. }

I have seen the link https://github.com/jmockit/jmockit1/issues/168 is this also fixing my issue with version 1.18???

rliesenfeld commented 9 years ago

The API documentation describes what you need, if I correctly understood it: http://jmockit.org/api1x/mockit/Tested.html#availableDuringSetup--

AmrutaM commented 9 years ago

Thanks @rliesenfeld that answered my question. :+1: