Skip to content

Abstract classes with @Nested are not ignored / not handled properly #2717

Closed
@Marcono1234

Description

@Marcono1234

Description

The predicate for whether a class annotated with @Nested can be executed does not check whether the class is abstract, see IsNestedTestClass. This causes a java.lang.InstantiationException when trying to run the tests (from within Eclipse IDE).

The predicate for top level test classes in IsPotentialTestContainer excludes abstract classes.

In case you decide to indeed ignore abstract nested classes, then error handling for that would probably have to be part of #242.

Steps to reproduce

Try to run the following test:

package test;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

public class NestedTestClass {
    @Nested
    public abstract class NestedClass {
        @Test
        public void test() {
            System.out.println("test");
        }
    }
}

Context

  • Used versions (Jupiter/Vintage/Platform): 5.8.0
  • Build Tool/IDE: Eclipse IDE 2021-06 (4.20.0)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions