Skip to content

Commit adacf7f

Browse files
committed
docs(k6): add usage example to module documentation
1 parent 2b53c47 commit adacf7f

File tree

1 file changed

+19
-33
lines changed

1 file changed

+19
-33
lines changed

docs/modules/k6.md

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
11
# k6 Module
22

3-
!!! note
4-
This module is INCUBATING.
5-
While it is ready for use and operational in the current version of Testcontainers, it is possible that it may receive breaking changes in the future.
6-
See [our contributing guidelines](/contributing/#incubating-modules) for more information on our incubating modules policy.
3+
!!! note
4+
This module is INCUBATING.
5+
While it is ready for use and operational in the current version of Testcontainers, it is possible that it may receive breaking changes in the future.
6+
See [our contributing guidelines](/contributing/#incubating-modules) for more information on our incubating modules policy.
77

88
Testcontainers module for [k6](https://registry.hub.docker.com/r/grafana/k6).
9-
109
[k6](https://k6.io/) is an extensible reliability testing tool built for developer happiness.
1110

12-
## Basic script execution
13-
14-
Execute a simple k6 test script, `test.js`, with commandline options and injected script variable.
15-
16-
Create a simple k6 test script to be executed as part of your tests:
17-
18-
<!--codeinclude-->
19-
[Setup the container](../../modules/k6/src/test/java/org/testcontainers/k6/K6ContainerTests.java) inside_block:standard_k6
20-
[Content of `scripts/test.js`](../../modules/k6/src/test/resources/scripts/test.js) inside_block:access_script_vars
21-
<!--/codeinclude-->
22-
23-
## Adding this module to your project dependencies
24-
25-
Add the following dependency to your `pom.xml`/`build.gradle` file:
26-
27-
=== "Gradle"
28-
```groovy
29-
testImplementation "org.testcontainers:testcontainers-k6:{{latest_version}}"
30-
```
31-
=== "Maven"
32-
```xml
33-
<dependency>
34-
<groupId>org.testcontainers</groupId>
35-
<artifactId>testcontainers-k6</artifactId>
36-
<version>{{latest_version}}</version>
37-
<scope>test</scope>
38-
</dependency>
39-
```
11+
## Usage
12+
13+
Here is a basic example of how to create and start a K6 container:
14+
15+
```java
16+
try (
17+
// k6_container {
18+
K6Container container = new K6Container(DockerImageName.parse("grafana/k6:0.49.0"))
19+
.withTestScript("scripts/test.js")
20+
.withScriptVar("MY_VAR", "hello")
21+
// }
22+
) {
23+
container.start();
24+
// Perform assertions based on logs or container state
25+
}

0 commit comments

Comments
 (0)