We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given is the following properties class
package com.bosch.modulith.foo; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "app.foo") public class FooProperties { private String prop1; private String prop2; public String getProp1() { return prop1; } public void setProp1(String prop1) { this.prop1 = prop1; } public String getProp2() { return prop2; } public void setProp2(String prop2) { this.prop2 = prop2; } }
and a regarding test
package com.bosch.modulith.foo; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.modulith.test.ApplicationModuleTest; import org.springframework.test.context.TestPropertySource; import static org.junit.jupiter.api.Assertions.assertEquals; @ApplicationModuleTest @TestPropertySource(properties = { "app.foo.prop1=foo1", "app.foo.prop2=foo2", }) class FooPropertiesTest { @Autowired FooProperties underTest; @Test void propertiesShouldSet() { assertEquals("foo1", underTest.getProp1()); assertEquals("foo2", underTest.getProp2()); } @Nested @TestPropertySource(properties = { "app.foo.prop1=nested-foo1", "app.foo.prop2=nested-foo2", }) class FooNestedTest { @Test void propertiesShouldSet() { assertEquals("nested-foo1", underTest.getProp1()); assertEquals("nested-foo2", underTest.getProp2()); } } }
I prepared an example project with two failing tests (one is using a "standard data class" as properties class and another is using a record instead) : https://github.com/pklink/spring-modulith-nested-test-properties
All tests should pass.
The nested test fails because the properties of the "outer test" are used.
[ERROR] FooPropertiesTest$FooNestedTest.propertiesShouldSet:36 expected: <nested-foo1> but was: <foo1>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Reproduce
Given is the following properties class
and a regarding test
Example
I prepared an example project with two failing tests (one is using a "standard data class" as properties class and another is using a record instead) : https://github.com/pklink/spring-modulith-nested-test-properties
Expected behavior
All tests should pass.
Actual Result
The nested test fails because the properties of the "outer test" are used.
The text was updated successfully, but these errors were encountered: