Wants to understand how @Tested works with JMockit

2.3k views Asked by At

I am using JMockit since long.I would like to understand how @Tested works.

Today i was trying to use it within my Test class. What i understand is Whatever class we wants to test we can mark it as @Tested.

One thing which was confusing me about the behaviur of this is when i try to set something in @Before.Below is my query.

My Class for which i want to write Test case

public  Class A{

    public A(){}

}

Test class

public class ATest {

    @Tested
    private A a;

    @Before
    public void setUp(){
        a.setSomething();
    }

    @Test
        public void testA(){
    }
}

In this case i get NPE. But if i use the same block of code in my test method directly that just works fine.Can anybody help me to understand the behavior of @Tested. I am using Jmockit version 1.17

I have also checked the post on GitHub as below: https://github.com/jmockit/jmockit1/issues/168 i just wanted to confirm is it also fixing my problem?

1

There are 1 answers

1
Amruta Mistry On BEST ANSWER

I was able to find what i was looking for http://jmockit.org/api1x/mockit/Tested.html#availableDuringSetup--