I'm writing a Spring Boot application and I want to make sure that I get reasonably well covered with tests.
Rather than writing unit tests it occurred to me that there should be tools available to help with that. Generate the required code stubs.
I'm not talking about generating the actual tests as this would be dangerous, but a tool that would generate test methods and I would then have to add the relevant code. Enough test methods should be generated to cover all branches of a method being tested. For example:
public void myComplicatedMethod(Integer i) {
if (i++ > 10) {
invokeOtherMethod(i);
} else {
throw new Exception("duh!");
}
}
Based on that code it is possible to identify a number of tests:
public void testShouldHandleNullI() {
}
public void testShouldInvokeOtherMethodIfILargerThan10() {
}
public void testShouldThrowExceptionIfINotLargerThan10() {
}
I'm thinking it should be possible to identify every path through the method and at the very least generate an equivalent test method name for that path.
I would then go through that code and write all the required tests.
Does anything like that exist either as a command line tool or an IDE extension?