often when i use powerMockito i wrtie this sentences PowerMockito.doReturn(message).when(messageDAOMock.save(message));
i get unfinishedstubbingexception and i don't know why and hoy i can correct it. also i put
@RunWith(PowerMockRunner.class)
@PrepareForTest(MessageService.class)
public class MessageServiceTest{
@Spy
MessageService serviceToTest = new MessageService();
@Spy
IMessageDAO messageDAOMock = new MessageDAO();
and i am using this dependencies:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4 -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.powermock/powermock-api-mockito2 -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.3.0</version>
</dependency>
and also i use junit 4.
tihs error sometimes it happens and sometimes it doesn't but i don't find out why or how i can solve it
thanks and sorry for my english, it is not my native languaje
I can solve this problem, the error is that in the parentesis, it is not
PowerMockito.doReturn(message).when(messageDAOMock.save(message));
else
PowerMockito.doReturn(message).when(messageDAOMock).save(message);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.