Skip to content

End-to-end testing documentation can be improved #1338

@3ric-T

Description

@3ric-T

Description

Documentation about end-to-end testing of a Spring Boot application can be improved.


Versions affected

  • Spring Shell 4.0.1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/need-triageTeam needs to triage and take a first look

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions