timothy
timothy

Reputation: 97

what are the Dependencies that i need to use junit 5 and junit 4?

since i am new at Junit 5 and i read that they are seperate the jars now in Junit 5, so what i need to attach?

i was looking at the maven repository and i found there much dependencies for junit 5 and i do not know what i should include for runing Junit 4 tests in Junit 5, and what is seperatly for Junit 5 alone?

i have no code yet but needs only the dependencies to understand what i need to download

also what the surefire does for all of these?

            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-surefire-provider</artifactId>
                <version>1.0.0-M4</version>
            </dependency>

update - so surefire is for search for the missing dependencies, what are does for?

   <dependency>
    <groupId>org.junit.platform</groupId>
    <artifactId>junit-platform-launcher</artifactId>
   <version>1.4.0-M1</version>
   <scope>test</scope>
     </dependency>
     <dependency>
     <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-runner</artifactId>
      <version>1.4.0-M1</version>
     <scope>test</scope>
  </dependency>
      <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-suite-api</artifactId>
        <version>1.4.0-M1</version>
       <scope>test</scope>
   </dependency>
    <dependency>
       <groupId>org.junit.platform</groupId>
         <artifactId>junit-platform-surefire-provider</artifactId>
        <version>1.3.2</version>
        <scope>test</scope>
      </dependency>
         <dependency>
         <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
          <version>5.4.0-M1</version>
          <scope>test</scope>
      </dependency>

Upvotes: 0

Views: 1453

Answers (1)

Vishwa Ratna
Vishwa Ratna

Reputation: 6390

Question: what the surefire does for all of these?

If in POM.xml your dependencies are not well mentioned then Surefire detects which JUnit version to use.

Surefire supports 3 different generations of JUnit: JUnit 3.8.x, JUnit 4.x (serial provider) and JUnit 4.7 (junit-core provider with parallel support)

The algorithm works something like this:

if the JUnit 5 Platform Engine is present in the project
    use junit-platform
if the JUnit version in the project >= 4.7 and the <<<parallel>>> configuration parameter has ANY value
    use junit47 provider
if JUnit >= 4.0 is present
    use junit4 provider
else
    use junit3.8.1

Edit: Dependencies required for Junit 5: ref1 , ref2

<dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>

Reference

Upvotes: 1

Related Questions