Skip to content

How to run a shell in an integration test in spring shell 4.x? #1274

@georgmittendorfer

Description

@georgmittendorfer

I would like to run a basic integration test that starts the interactive or non-interactive shell to verify that the spring application is able to properly start up.

In spring shell 3.x I did:

@Test
void nonInteractiveShellStarts() {
  ShellTestClient.InteractiveShellSession session = client.interactive().run();
  await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> ShellAssertions.assertThat(session.screen()).containsText("shell"));
  session.write(session.writeSequence().text("help").carriageReturn().build());
  await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> ShellAssertions.assertThat(session.screen()).containsText("...")); // check that all commands are registered
}

In spring shell 4.x I tried:

@Test
void interactiveShellStarts(@Autowired ShellTestClient client) throws Exception {
	client.sendCommand("help"); // throws command not found
}

How could I do a basic smoke test to see if the spring shell starts properly and all my commands are registered and shown with the 'help' command?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions