0

I have a class that contains a new() call like this:

public class TestService {
    public String test(String test) {
        String data = new Engine().getData();
        return test + data;
    }
}

I can't modify the code, is it possible using Mockito to mock new Engine().getData()?

user1715772
  • 1
  • 1
  • 1
  • 1
    Does this answer your question? [Mockito - mocking legacy class constructor](https://stackoverflow.com/questions/6288575/mockito-mocking-legacy-class-constructor) – maloomeister Jan 24 '22 at 10:05
  • @maloomeister i can't modify the code or use the PowerMock,so the answer is invalid – user1715772 Jan 24 '22 at 11:52

0 Answers0