From 46e4c4ba769d775ec0f972c51b64cd84a87b7bf0 Mon Sep 17 00:00:00 2001 From: meyonsoo Date: Tue, 10 Mar 2026 22:19:13 +0900 Subject: [PATCH] docs: add JUnit-style example test to k6 module docs --- docs/modules/k6.md | 9 +++++++-- .../java/org/testcontainers/k6/K6ContainerTests.java | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index 4783ca1e5ad..1a13c09e895 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -11,12 +11,17 @@ 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. +The following example shows a typical JUnit 5 test that runs a k6 script inside a container, waits for the run to finish, and asserts on the output. + + +[Running a k6 script in a JUnit test](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6_test + + +The test above uses a simple k6 script, `test.js`, with command line options and an injected script variable. Create a simple k6 test script to be executed as part of your tests: -[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 diff --git a/modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java b/modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java index 255cb376b4f..1cfc18a72c5 100644 --- a/modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java +++ b/modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java @@ -12,6 +12,7 @@ class K6ContainerTests { @Test void k6StandardTest() throws Exception { + // standard_k6_test { try ( // standard_k6 { K6Container container = new K6Container("grafana/k6:0.49.0") @@ -37,5 +38,6 @@ void k6StandardTest() throws Exception { assertThat(container.getLogs()).contains("k6 tests are cool!"); } + // } } }