Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/modules/k6.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ Testcontainers module for [k6](https://registry.hub.docker.com/r/grafana/k6).

## Basic script execution

Execute a simple k6 test script, `test.js`, with commandline options and injected script variable.
You can start a K6 container instance from any Java application by using:

<!--codeinclude-->
[Setup the container](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6
<!--/codeinclude-->

The test above uses a simple k6 script, `test.js`, with command line options and an injected script variable.

Once the container is started, you can wait for the test results to be collected:

<!--codeinclude-->
[Wait for test results](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:wait
<!--/codeinclude-->

Create a simple k6 test script to be executed as part of your tests:

<!--codeinclude-->
[Setup the container](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6
[Content of `scripts/test.js`](../../modules/k6/src/test/resources/scripts/test.js) inside_block:access_script_vars
<!--/codeinclude-->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void k6StandardTest() throws Exception {
) {
container.start();

// wait {
WaitingConsumer consumer = new WaitingConsumer();
container.followOutput(consumer);

Expand All @@ -34,6 +35,7 @@ void k6StandardTest() throws Exception {
3,
TimeUnit.SECONDS
);
// }

assertThat(container.getLogs()).contains("k6 tests are cool!");
}
Expand Down
Loading