Skip to content

Tests within inner classes that are children of an abstract class are not executed despite @Nested #4125

@SIMULATAN

Description

@SIMULATAN

Expected

Tests declared within a @Nested inner class inheriting from their parent abstract class should run out of the box.

Actual

No tests are picked up.

Rationale

I want to test multiple strategies (MapperEngine). In order to verify feature parity, the tests are abstract functions.
To avoid boilerplate and group the tests, the strategy implementation verifications are inner classes of the abstract class.

Steps to reproduce

abstract class MapperEngineTest {
  abstract fun map()

  @Nested
  inner class Liquid : MapperEngineTest() {
    @Test
    // this test should run, but it doesn't
    override fun map() { ... }
  }

  @Nested
  inner class Replace {
    @Test
    // doesn't run either (this time without inheriting the abstract class)
    fun map() { ... }
  }
}

Context

  • Used versions: JUnit 5.10.2
  • Build Tool/IDE: Gradle 8.10.2, IntelliJ 2024.3 RC

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions