Der Maven -Unit -Test schlägt in Jenkins fehlJava

Java-Forum
Anonymous
 Der Maven -Unit -Test schlägt in Jenkins fehl

Post by Anonymous »

Ich habe eine Spring -Boot -Anwendung, die Dateien (HTML, PDF, XML usw.) verarbeitet und einige Konvertierungen durchführt. Im Folgenden finden Sie die Spezifikation des Projekts: < /p>
  • Code: Select all

    Java (Amazon Coretto) 17.0.14_7
  • Code: Select all

    Maven 3.9.9
  • Code: Select all

    Spring Boot 2.7.6
  • Code: Select all

    Spring Cloud 2021.0.7
  • Code: Select all

    Spring Boot Maven Plugin 2.7.6
  • Code: Select all

    Maven Surefire Plugin 3..5.2
    mit KonfigurationsreUSEFORKS als false und forkCount as 1c
Das Projekt hat eine pipeline.yml Konfiguration für Jenkins CI:

Code: Select all

language:
java:
name: "amazon-coretto"
version: "17.0.5.8.1"
tools:
maven:
name: "maven"
version: "3.9.9"
< /code>
In dieser Anwendung gibt es einen Unit-Testfall, der die folgende Struktur hat: < /p>
private String source;
private String expected;

@BeforeEach
public void setup() throws IOException {
final InputStreamReader expectedStream = new InputStreamREader(getClass().getResourceAsStream("expected_file.html"), StandardCharsets.UTF_8);
final InputStreamReader sourceStream = new InputStreamREader(getClass().getResourceAsStream("source_file.html"), StandardCharsets.UTF_8);
// IOUtils from Apache Common IO
expected = IOUtils.toString(expectedReader);
source = IOUtils.toString(source);
}

@Test
void testCase() throws IOException {
String result = // Some Internal call to a method to produce output;
assertEquals(expected, result);
}
< /code>
Der obige Testfall Pass in der lokalen Umgebung. Wenn der Code jedoch in Jenkins zusammengeführt und eingebaut wird, fehlschlägt der obige Testfall. Bei der Beobachtung der Protokolle schlägt die gleiche Behauptung aus, aber die beiden im Protokoll gedruckten Werte sind tatsächlich gleich. Die Quelle und die erwarteten Dateien enthalten einen HTML -Code und sind beide in /src/test/ressourcen/
vorhanden. Der Unit -Test fehlschlägt nur, wenn die Maven -Spezifikation in Pipeline.yml angegeben ist. Wenn diese Konfiguration weggelassen wird, g e h t d e r T e s t f a l l i n C I . < c o d e > a t o r g . j u n i t . j u p i t e r . a p i . A s s e r t i o n U t i l s . f a i l ( A s s e r t i o n U t i l s . j a v a : 5 5 ) < b r / > a t o r g . j u n i t . j u p i t e r . a p i . A s s e r t i o n U t i l s . f a i l N o t E q u a l ( A s s e r t i o n U t i l s . j a v a : 6 2 ) < b r / > a t o r g . j u n i t . j u p i t e r . a p i . A s s e r t E q u a l s . a s s e r t E q u a l s ( A s s e r t E q u a l s . j a v a : 1 8 2 ) < b r / > a t o r g . j u n i t . j u p i t e r . a p i . A s s e r t E q u a l s . a s s e r t E q u a l s ( A s s e r t E q u a l s . j a v a : 1 7 7 ) < b r / > a t o r g . j u n i t . j u p i t e r . a p i . A s s e r t i o n s . a s s e r t E q u a l s ( A s s e r t i o n s . j a v a : 1 1 4 1 ) < b r / > a t & l t ; p a c k a g e & g t ; . F i l e P r o c e s s o r . t e s t C a s e ( F i l e P r o c e s s o r . j a v a : 3 6 ) < b r / > a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) < b r / > a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 7 7 ) < b r / > a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 4 3 ) < b r / > a t j a v a . b a s e / j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 5 6 9 ) < b r / > a t o r g . j u n i t . p l a t f o r m . c o m m o n s . u t i l . R e f l e c t i o n U t i l s . i n v o k e M e t h o d ( R e f l e c t i o n U t i l s . j a v a : 7 2 5 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . M e t h o d I n v o c a t i o n . p r o c e e d ( M e t h o d I n v o c a t i o n . j a v a : 6 0 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . I n v o c a t i o n I n t e r c e p t o r C h a i n $ V a l i d a t i n g I n v o c a t i o n . p r o c e e d ( I n v o c a t i o n I n t e r c e p t o r C h a i n . j a v a : 1 3 1 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x t e n s i o n . T i m e o u t E x t e n s i o n . i n t e r c e p t ( T i m e o u t E x t e n s i o n . j a v a : 1 4 9 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x t e n s i o n . T i m e o u t E x t e n s i o n . i n t e r c e p t T e s t a b l e M e t h o d ( T i m e o u t E x t e n s i o n . j a v a : 1 4 0 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x t e n s i o n . T i m e o u t E x t e n s i o n . i n t e r c e p t T e s t M e t h o d ( T i m e o u t E x t e n s i o n . j a v a : 8 4 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . E x e c u t a b l e I n v o k e r $ R e f l e c t i v e I n t e r c e p t o r C a l l . l a m b d a $ o f V o i d M e t h o d $ 0 ( E x e c u t a b l e I n v o k e r . j a v a : 1 1 5 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . E x e c u t a b l e I n v o k e r . l a m b d a $ i n v o k e $ 0 ( E x e c u t a b l e I n v o k e r . j a v a : 1 0 5 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . I n v o c a t i o n I n t e r c e p t o r C h a i n $ I n t e r c e p t e d I n v o c a t i o n . p r o c e e d ( I n v o c a t i o n I n t e r c e p t o r C h a i n . j a v a : 1 0 6 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . I n v o c a t i o n I n t e r c e p t o r C h a i n . p r o c e e d ( I n v o c a t i o n I n t e r c e p t o r C h a i n . j a v a : 6 4 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . I n v o c a t i o n I n t e r c e p t o r C h a i n . c h a i n A n d I n v o k e ( I n v o c a t i o n I n t e r c e p t o r C h a i n . j a v a : 4 5 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . I n v o c a t i o n I n t e r c e p t o r C h a i n . i n v o k e ( I n v o c a t i o n I n t e r c e p t o r C h a i n . j a v a : 3 7 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . E x e c u t a b l e I n v o k e r . i n v o k e ( E x e c u t a b l e I n v o k e r . j a v a : 1 0 4 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . e x e c u t i o n . E x e c u t a b l e I n v o k e r . i n v o k e ( E x e c u t a b l e I n v o k e r . j a v a : 9 8 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . T e s t M e t h o d T e s t D e s c r i p t o r . l a m b d a $ i n v o k e T e s t M e t h o d $ 7 ( T e s t M e t h o d T e s t D e s c r i p t o r . j a v a : 2 1 4 ) < b r / > a t o r g . j u n i t . p l a t f o r m . e n g i n e . s u p p o r t . h i e r a r c h i c a l . T h r o w a b l e C o l l e c t o r . e x e c u t e ( T h r o w a b l e C o l l e c t o r . j a v a : 7 3 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . T e s t M e t h o d T e s t D e s c r i p t o r . i n v o k e T e s t M e t h o d ( T e s t M e t h o d T e s t D e s c r i p t o r . j a v a : 2 1 0 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . T e s t M e t h o d T e s t D e s c r i p t o r . e x e c u t e ( T e s t M e t h o d T e s t D e s c r i p t o r . j a v a : 1 3 5 ) < b r / > a t o r g . j u n i t . j u p i t e r . e n g i n e . d e s c r i p t o r . T e s t M e t h o d T e s t D e s c r i p t o r . e x e c u t e ( T e s t M e t h o d T e s t D e s c r i p t o r . j a v a : 6 6 ) < b r / > a t o r g . j u n i t . p l a t f o r m . e n g i n e . s u p p o r t . h i e r a r c h i c a l . N o d e T e s t T a s k . l a m b d a $ e x e c u t e R e c u r s i v e l y $ 6 ( N o d e T e s t T a s k . j a v a : 1 5 1 ) < b r / > a t o rg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.apache.maven.surefire.junitplatform.LazyLauncher.execute(LazyLauncher.java:56)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.execute(JUnitPlatformProvider.java:184)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:148)
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post