Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Improved Helidon MP testing #9695

Merged
merged 2 commits into from
Feb 4, 2025
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
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,11 @@
<artifactId>helidon-common-testing-virtual-threads</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-junit5</artifactId>
Expand Down
5 changes: 3 additions & 2 deletions common/testing/virtual-threads/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oracle and/or its affiliates.
* Copyright (c) 2024, 2025 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,8 @@
module io.helidon.common.testing.vitualthreads {
requires jdk.jfr;
exports io.helidon.common.testing.virtualthreads to
io.helidon.microprofile.testing,
io.helidon.microprofile.testing.junit5,
io.helidon.microprofile.testing.testng,
io.helidon.webserver.testing.junit5;
}
}
10 changes: 10 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@
<artifactId>helidon-microprofile-testing-junit5</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.testing</groupId>
<artifactId>helidon-microprofile-testing-testng</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
6 changes: 5 additions & 1 deletion docs/src/main/asciidoc/includes/attributes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ endif::[]
:metrics-serviceapi-javadoc-base-url: {javadoc-base-url}/io.helidon.metrics.serviceapi
:micrometer-javadoc-base-url: {javadoc-base-url}/io.helidon.integrations.micrometer
:prometheus-javadoc-base-url: {javadoc-base-url}/io.helidon.metrics.prometheus
:mp-config-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.config
:mp-cors-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.cors
:mp-restclient-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.restclient
:mp-server-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.server
:mp-tyrus-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.tyrus
:mp-restclient-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.restclient
:mp-testing-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.testing
:mp-junit5-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.testing.junit5
:mp-mocking-javadoc-base-url: {javadoc-base-url}/io.helidon.microprofile.testing.mocking
:openapi-javadoc-base-url: {javadoc-base-url}/io.helidon.openapi
:openapi-ui-javadoc-base-url: {javadoc-base-url}/io.helidon.integrations.openapi.ui
:reactive-base-url: {javadoc-base-url}/io.helidon.common.reactive
Expand Down
21 changes: 14 additions & 7 deletions docs/src/main/asciidoc/mp/guides/testing-junit5.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2021, 2024 Oracle and/or its affiliates.
Copyright (c) 2021, 2025 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -95,20 +95,27 @@ The test is now complete and verifies the message.

The testing extension supports a few additional annotations that allow for finer control of the test execution.


.Optional Extension Annotations
[width="70%",options="header"]
[cols="1,3"]
|====================
| Annotation | Description
| `@HelidonTest(resetPerTest = true)` | Resets the container for each method.

| `@HelidonTest(resetPerTest = true)`
| Resets the container for each method.
This is useful when we want to modify configuration or beans between executions. In such a case, injection into fields is not possible, as we would need a different instance for each test.
| `@AddConfig(key = "app.greeting", value = "Unite")` | Define additional configuration (either on class level, or method level) by adding a single configuration key/value.

| `@AddConfig(key = "app.greeting", value = "Unite")`
| Define additional configuration (either on class level, or method level) by adding a single configuration key/value.

| `@AddConfigBlock(type = "properties", value = """ +
some.key1=some.value1 +
some.key2=some.value2 +
""")` | Define additional configuration (either on class level, or method level) by adding one or more configuration key/value pairs.
| `@Configuration(configSources = "test-config.properties")` | Adds a whole config source from classpath.
""")`
| Define additional configuration (either on class level, or method level) by adding one or more configuration key/value pairs.

| `@Configuration(configSources = "test-config.properties")`
| Adds a whole config source from classpath.

|====================

Here's an example showing how these approaches are used to execute the same endpoint with different configuration:
Expand Down
Loading
Loading