I have a class written that extends Runner (org.junit.runner.Runner), which is a part of the junit-4.13.2.jar. I am trying to migrate to JUnit 5 without using the JUnit Vintage engine. Is there a counterpart for the same class in JUnit 5, i.e., is there a way to migrate completely to JUnit 5?
            Asked
            
        
        
            Active
            
        
            Viewed 75 times
        
    0
            
            
         
    
    
        Harry Coder
        
- 2,429
- 2
- 28
- 32
 
    
    
        Dhanyaa Bharadwaj
        
- 13
- 4
- 
                    JUnit 5 uses extensions for this. – M. Deinum Feb 16 '23 at 10:08
- 
                    In `JUnit 5` we use `@ExtendWith`. Take a look here for more details: https://www.baeldung.com/junit-5-runwith – Harry Coder Feb 16 '23 at 14:51
- 
                    This question explains it nicely: https://stackoverflow.com/questions/55276555/when-to-use-runwith-and-when-extendwith – Feb 16 '23 at 15:05
- 
                    It really depends on the exact runners you’re using. Some have an equivalent extension, some require another test-engine, for others you’ll have to do the migration to a JUnit5 extension yourself. In very rare cases, a 1-1 migration might not be possible at all. So which runners are you talking about? – johanneslink Feb 16 '23 at 18:53
- 
                    @M.Deinum, what extensions? – Dhanyaa Bharadwaj Feb 17 '23 at 05:25
- 
                    @johanneslink, I am talking about the abstract class (public abstract class Runner implements Describable), from the package org.junit.runner – Dhanyaa Bharadwaj Feb 17 '23 at 06:17
- 
                    As said, there’s no generic solution for the abstract Runner. There are only solutions for concrete usages. – johanneslink Feb 17 '23 at 06:21
- 
                    The one that are used with `@ExtendWith` which also need a specific interface to implement. You probably need to rewrite your runner for that, or if it is a 3rd party runner look for the JUnit5 alternative, if there isn't keep using JUnit4 (through the vintage runner) or rewrite it yourself. – M. Deinum Feb 20 '23 at 07:10