[ 
https://issues.apache.org/jira/browse/SUREFIRE-1372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16285308#comment-16285308
 ] 

ASF GitHub Bot commented on SUREFIRE-1372:
------------------------------------------

Github user mpkorstanje commented on the issue:

    https://github.com/apache/maven-surefire/pull/150
  
    > Why you have chosen provider surefire-junit47 and not also the 
surefire-junit4?
    
    While it would be possible to change surefire-junit4 to filter by 
description there is no need to. Prior to JUnit 4.11 descriptions use their 
display name to test for equality. The display name was composed of a method 
name and a class name. As such filtering by a description created from the 
method and class name of a failed test and filtering by the description of that 
failed test will yield the same result.
    
    ```java
    Description failedTestDescription = 
Description.createTestDescription(Test.class, "shouldTestSomething");
    Description descriptionFromFailedMethodAndClassName = 
Description.createTestDescription(Test.class, "shouldTestSomething");
    
    assertEquals(failedTestDescription, 
descriptionFromFailedMethodAndClassName);
    assertEquals(failedTestDescription.getDisplayName(), 
descriptionFromFailedMethodAndClassName.getDisplayName());
    ```
    
    > Why the method generateFailingTestDescriptions has to return 
Set<Description> and not the previous Map<Class<?>, Set<String>>?
    
    With the introduction of the `fUniqueId` property to test for equality 
between descriptions in JUnit 4.11 filtering by a description created from the 
method and class name of a failed test and filtering by the description of that 
failed test are no longer the same. Hence the need to use the description of 
the failed test instead of its method and class name.
    
    For example:
    
    ```java
    Description failedTestDescription = 
Description.createTestDescription(Test.class.getCanonicalName(), 
"shouldTestSomething", "my-test-id");
    Description descriptionFromFailedMethodAndClassName = 
Description.createTestDescription(Test.class, "shouldTestSomething");
    
    
    assertNotEquals(failedTestDescription, 
descriptionFromFailedMethodAndClassName);
    assertEquals(failedTestDescription.getDisplayName(), 
descriptionFromFailedMethodAndClassName.getDisplayName());
    ```
    
    
    
    



> Rerunning failing tests fails in combination with 
> Description#createSuiteDescription
> ------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-1372
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1372
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Maven Surefire Plugin
>    Affects Versions: 2.20
>            Reporter: M.P. Korstanje
>            Assignee: Tibor Digana
>             Fix For: 2.21.1
>
>
> When using surefire to rerun failing tests created by a Runner that uses 
> {noformat}Description#createSuiteDescription{noformat} with a human readable 
> name rather then a class name the following stack trace occurs:
> {code}
> org.apache.maven.surefire.testset.TestSetFailedException: Unable to create 
> test class 'Scenario: Fail when running'
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:385)
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:292)
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
> Caused by: java.lang.ClassNotFoundException: Scenario: Fail when running
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379)
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:292)
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
>         at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to