how to mock class variables using mockito java

Sathish David  Kumar N
Sathish David  Kumar N used Ask the Experts™
on
how to mock class variables using mockito java

In my class i declare String variable , i want to mock the value how to do that

class A{

  @Value("${COUNT_SQL}")
private String test="sql query";

}
i want to mock this test
I used MemberMatcher.field but its not working giving Null pointer exception
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer

Commented:
Why mocking a private field?
while doing unit test its thorwing null pointer exception
ste5anSenior Developer

Commented:
Then you have already found a bug/glitch. This should not happen at all.
Wrong mocking

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial