如何让 gradle 和 Junit5 使用名为 *Should 的测试 类?

How to get gradle and Junit5 to use test classes that are named *Should?

Junit5 的 gradle 插件查找名为“*Test”的测试 类。我们的名称也为“* Should”,但未被检测到。我怎样才能让 gradle 去接他们?

来自 the docs ...

Configuring Filters

You can configure filters for the test plan by using the filters extension. By default, all engines and tags are included in the test plan. Only the default includeClassNamePattern (^.*Tests?$) is applied. You can override the default pattern as in the following example. When you specify multiple patterns, they are combined using OR semantics.

junitPlatform {
    // ...
    filters {
        engines {
            include 'junit-jupiter'
            // exclude 'junit-vintage'
        }
        tags {
            include 'fast', 'smoke'
            // exclude 'slow', 'ci'
        }
        packages {
            include 'com.sample.included1', 'com.sample.included2'
            // exclude 'com.sample.excluded1', 'com.sample.excluded2'
        }
        includeClassNamePattern '.*Spec'
        includeClassNamePatterns '.*Test', '.*Tests'
    }
    // ...
}

我怀疑您需要指定 includeClassNamePattern '.*Test', '.*Should'