Wie kann ich meine Profile testen?Spring Boot Profil. Wie testen?
, dass mein Test ist
@Test
public void testDevProfile() throws Exception {
System.setProperty("spring.profiles.active", "dev");
Application.main(new String[0]);
String output = this.outputCapture.toString();
Assert.assertTrue(output.contains("The following profiles are active: dev"));
}
@Test
public void testUatProfile() throws Exception {
System.setProperty("spring.profiles.active", "uat");
Application.main(new String[0]);
String output = this.outputCapture.toString();
Assert.assertTrue(output.contains("The following profiles are active: uat"));
}
@Test
public void testPrdProfile() throws Exception {
System.setProperty("spring.profiles.active", "prd");
Application.main(new String[0]);
String output = this.outputCapture.toString();
Assert.assertFalse(output.contains("The following profiles are active: uat"));
Assert.assertFalse(output.contains("The following profiles are active: dev"));
Assert.assertFalse(output.contains("The following profiles are active: default"));
}
Mein erster Test führt in Ordnung, aber die anderen nicht.
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [[email protected]6cbe68e9] with key 'requestMappingEndpoint'; nested exception is javax.management.InstanceAlreadyExistsException: org.springframework.boot:type=Endpoint,name=requestMappingEndpoint
Wie kann ich die Instanz vor dem nächsten Teststart stoppen? Oder welcher ist der bessere Ansatz?
dank