-
Jul 20th, 2011, 03:46 PM
#1
Help - Unit Testing with @Autowired private fields - most concise way ?
Hi,
I have a class that I want to unit test. The class hasa n autowired PRIVATE member. This member is a service that does some db calls etc.
I'm writing a unit test and obviously want to mock the autowired/injected member (using mockito).
But, how do I plugin the mock into the class I want to test ?
Obviously I can right a setter (hate polluting with silly code though) or I can just make the member 'package private' and simple set it directly from the test, but I would like to avoid this as it will show up as a violation on our static code analysis report (sonar)
any ideas ?
thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules