I am new to Unit testing and using Mockito framework.
I have a Java class and have the main() method in it. In my Main() method I have several other methods that I need to Unit test.
This is my class to test
public class client{
public static void main(String[] args) {
Ip ip = createIpEvent();
.
.
.
}
private static Ip createIpEvent(){
Ip ip = new Ip();
ip.setters(); // various setters
return ip;
}
}
This is my Test class that I am making.
public class clientTest{
client clientMock = mock(client.class);
@Test
public void testCreateIpEvent(){
Ip ip = new Ip();
//setters....
try(MockedStatic<client> utils = Mockito.mockStatic(client.class)){
utils.when(() -> client.main()....)
//here I am only able to access the main() method and not the method createIpEvent()
}
}
Please some one help me out on this.