Skip to content

@Tag works only if placed on method but not on class #12

@TimurKasatkin

Description

@TimurKasatkin

Let's us consider following example:

import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test

class Test1 {

    @Test
    @Tag("tag1")
    suspend fun testCase1() {
        //...
    }

}

@Tag("tag1")
class Test2 {

    @Test
    suspend fun testCase2() {
        //...
    }
}

If junit5 tests launched with tag tag1, only Test1#testCase1 will run, but not test methods of class Test2.

Environment 1:

  • java 11.0.5-BellSoft
  • IntelliJ IDEA 2020.3.2 (Ultimate Edition)

Environment 2:

  • java 11.0.5-BellSoft
  • maven 3.6.3
  • maven surefire-plugin 2.22.2

After some short research and debug, I have discovered that both CorounitClassDescriptior and CorounitMethodDescriptior have correct values of getTags() method from org.junit.platform.engine.support.descriptor.AbstractTestDescriptor, but only methods marked by @Tag annotation are ran.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions