1- package io .qameta .allure ;
1+ package io .qameta .allure . junit5 ;
22
3- import io .qameta .allure .util .ResultsUtils ;
3+ import io .qameta .allure .Allure ;
4+ import io .qameta .allure .AllureLifecycle ;
45import io .qameta .allure .model .Stage ;
6+ import io .qameta .allure .model .Status ;
57import io .qameta .allure .model .TestResult ;
8+ import io .qameta .allure .util .ResultsUtils ;
69import org .junit .platform .engine .TestExecutionResult ;
710import org .junit .platform .launcher .TestExecutionListener ;
811import org .junit .platform .launcher .TestIdentifier ;
@@ -46,7 +49,7 @@ public void executionStarted(final TestIdentifier testIdentifier) {
4649 final TestResult result = new TestResult ()
4750 .withUuid (uuid )
4851 .withName (testIdentifier .getDisplayName ())
49- .withHistoryId (md5 (testIdentifier . getUniqueId () ))
52+ .withHistoryId (getHistoryId (testIdentifier ))
5053 .withStage (Stage .RUNNING );
5154 getLifecycle ().scheduleTestCase (result );
5255 getLifecycle ().startTestCase (uuid );
@@ -63,7 +66,7 @@ public void executionFinished(final TestIdentifier testIdentifier, final TestExe
6366 switch (testExecutionResult .getStatus ()) {
6467 case FAILED :
6568 testExecutionResult .getThrowable ().ifPresent (throwable -> {
66- result .setStatus (ResultsUtils . getStatus (throwable ). orElse ( FAILED ));
69+ result .setStatus (getStatus (throwable ));
6770 result .setStatusDetails (ResultsUtils .getStatusDetails (throwable ).orElse (null ));
6871 });
6972 break ;
@@ -83,6 +86,14 @@ public void executionFinished(final TestIdentifier testIdentifier, final TestExe
8386 }
8487 }
8588
89+ protected Status getStatus (final Throwable throwable ) {
90+ return ResultsUtils .getStatus (throwable ).orElse (FAILED );
91+ }
92+
93+ protected String getHistoryId (final TestIdentifier testIdentifier ) {
94+ return md5 (testIdentifier .getUniqueId ());
95+ }
96+
8697 private String md5 (final String source ) {
8798 final byte [] bytes = getMessageDigest ().digest (source .getBytes (UTF_8 ));
8899 return new BigInteger (1 , bytes ).toString (16 );
0 commit comments