I'm using Mockito as mocking library. The issue is reproduced for all mocking style types: with annotations, without annotations.
Steps to reproduce:
~~~~~~~~~~~~~~~~
1. Prerequisites:
public interface FirstService {}
public interface SecondService {}
public class SecondServiceImpl implements SecondService {
private FirstService firstService;
public void foo() {}
public void setFirstService(FirstService firstService) {
this.firstService = firstService;
}
}
2. Select Mock Dependencies in Test Case(Ctrl + Alt + Shift + M) option in MoreUnit. Select FirstService to be mocked.
Expected results:
~~~~~~~~~~~~~~
Compile-able test class with mocked dependencies.
Actual result:
~~~~~~~~~~~
The generated test class doesn't compile due to bad syntax.
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeMethod;
public class SecondServiceImplTest {@Mock
private FirstService firstService;@InjectMocks
private SecondServiceImpl secondServiceImpl;@BeforeMethod
public void createSecondServiceImpl() throws Exception MockitoAnnotations.initMocks(this);{}
}
Hi Andrei,
Sorry for not having answered sooner. I tried to reproduce your problem last week but I couldn't. Could you tell me which version of Eclipse you are using? Also, could you confirm that you installed this version from the update site (we had a problem with the file uploaded to SourceForge's files section).
Again, thanks again for all your reports,
Nicolas
I'm using Eclipse 4.2.2 (Juno Service Release 2) and yes, I installed it through update site (actually it was an update from 3.0.1).
I tried again and could not reproduce this problem. I'm closing it as "out of date", but don't hesitate to open a new ticket if the problem reappears.