Description
Documentation about end-to-end testing of a Spring Boot application can be improved.
Versions affected
Details
End-to-end testing of a Spring Boot application can be acheived following the documentation:
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
useMainMethod = SpringBootTest.UseMainMethod.ALWAYS,
classes = { MyShellApplication.class },
properties = { "spring.shell.interactive.enabled=false" },
args = "hi")
@ExtendWith(OutputCaptureExtension.class)
public class ShellApplicationEndToEndTests {
@Test
void testCommandOutput(CapturedOutput output) {
assertThat(output).contains("Hello world!");
}
}
This isn't very effective if there are a lot of commands to test. Fortunately, it can be improved by mixing both @ShellTest and @SpringBoot:
@ShellTest
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
useMainMethod = SpringBootTest.UseMainMethod.ALWAYS,
classes = MatosShellApplication.class,
properties = "spring.shell.interactive.enabled=false")
class ShellApplicationEndToEndTests {
@Test
void testCommandExecution(@Autowired ShellTestClient client) throws Exception {
// when
ShellScreen shellScreen = client.sendCommand("help");
// then
ShellAssertions.assertThat(shellScreen).containsText("AVAILABLE COMMANDS");
}
}
If this is to be the standard practice, then it should be documented.
Description
Documentation about end-to-end testing of a Spring Boot application can be improved.
Versions affected
4.0.1Details
End-to-end testing of a Spring Boot application can be acheived following the documentation:
This isn't very effective if there are a lot of commands to test. Fortunately, it can be improved by mixing both
@ShellTestand@SpringBoot:If this is to be the standard practice, then it should be documented.