Skip to content

Commit a756bc6

Browse files
Improve k6 docs (#11564)
Fixes #8780 --------- Co-authored-by: Eddú Meléndez Gonzales <eddu.melendez@gmail.com>
1 parent 5323acd commit a756bc6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

docs/modules/k6.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,23 @@ Testcontainers module for [k6](https://registry.hub.docker.com/r/grafana/k6).
1111

1212
## Basic script execution
1313

14-
Execute a simple k6 test script, `test.js`, with commandline options and injected script variable.
14+
You can start a K6 container instance from any Java application by using:
15+
16+
<!--codeinclude-->
17+
[Setup the container](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6
18+
<!--/codeinclude-->
19+
20+
The test above uses a simple k6 script, `test.js`, with command line options and an injected script variable.
21+
22+
Once the container is started, you can wait for the test results to be collected:
23+
24+
<!--codeinclude-->
25+
[Wait for test results](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:wait
26+
<!--/codeinclude-->
1527

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

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

modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void k6StandardTest() throws Exception {
2323
) {
2424
container.start();
2525

26+
// wait {
2627
WaitingConsumer consumer = new WaitingConsumer();
2728
container.followOutput(consumer);
2829

@@ -34,6 +35,7 @@ void k6StandardTest() throws Exception {
3435
3,
3536
TimeUnit.SECONDS
3637
);
38+
// }
3739

3840
assertThat(container.getLogs()).contains("k6 tests are cool!");
3941
}

0 commit comments

Comments
 (0)