how to mock class variables using mockito java

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
LVL 20
Sathish David  Kumar NArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Why mocking a private field?
0
Sathish David Kumar NArchitectAuthor Commented:
while doing unit test its thorwing null pointer exception
0
ste5anSenior DeveloperCommented:
Then you have already found a bug/glitch. This should not happen at all.
0
Sathish David Kumar NArchitectAuthor Commented:
Wrong mocking
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JUnit

From novice to tech pro — start learning today.