![]() ![]() MethodNotFoundException: No method found with name ‘myMethod’ with parameter types: in class .service.MyService.Īt .WhiteboxImpl.throwExceptionIfMethodWasNotFound(WhiteboxImpl.java:1167)Īt .(MemberMatcher.java:82)Īt .(MyServiceIT. TestMyMethod(.service.MyServiceIT) Time elapsed: 46.084 sec <<< ERROR! Protected access gives the subclass a chance to use the helper method or variable, while preventing a nonrelated class from trying to use it. Methods, fields can be declared protected, however methods and fields in a interface cannot be declared protected. How can I accurately mock the private method? The protected access modifier cannot be applied to class and interfaces. withArguments(Matchers.any(byte.class), Matchers.any(UserFile.class), Matchers.any(User.class)) PowerMockito.doNothing().when(m_mySvcSpy, thod(MyService.class, “myMethod”, byte.class, UserFile.class, User.class)) M_mySvcSpy = PowerMockito.spy(m_userFileSvc) Private MyService final void setup() throws Exception Private void myMethod(byte data, UserFile userFile, User user)Īnd here’s what I’m trying to do in my JUnit test "classpath:test-context.xml" class PowerMockRule rule = new MyService m_mySvc ![]() Here is the class with the private method class MyServiceImpl implements MyService ![]() I want to mock a private method, but I’m confused how do it when the declared class of my spied object is actually an interface. If a class, method or variable is entitled as private in the program, that means that a particular class, method or variable cannot be accessed by outside the class or method, unlike the public method. I’m using Mockito 1.9.5, PowerMock 1.5.6, JUnit 4.11, and Spring 3.1.4.RELEASE. The keyword ‘private’ in Java is used to establish the limitation of accessibility of the class, method or a variable in the java code block. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |