[bug] Running tests by module or by name no longer possible in 6.3+?

33 views
Skip to first unread message

Petr Bodnár

unread,
Apr 3, 2021, 5:56:21 AM4/3/21
to CAS Community
Hello,

this post is may be interesting for CAS contributors...

I try to run CAS's JUnit-based unit tests from command line, i. e. via Gradle - see https://apereo.github.io/cas/development/developer/Test-Process.html#unit--integration-testing. I've run into the following problems though that are not present in the 6.2.x branch, so it seems like a novelty in the 6.3.x and master branches.

Note that I'm intentionally leaving just the necessary command line parameters in the examples below in order to keep it short.

1) Running tests just from one module is not possible

This is not documented, yet it is working in 6.2.x. For example:

$ ./gradlew :core:cas-server-core-authentication {cleanTest,testSimple} --info

Unexpected result:

...
> Task :core:cas-server-core-authentication:testSimple SKIPPED
Skipping task ':core:cas-server-core-authentication:testSimple' as task onlyIf is false.
:core:cas-server-core-authentication:testSimple (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.

2) Running a single test is not possible

For example (note that the `--category` switch seems to be mandatory, there is probably some technical reason behind always filtering tests by their `@Tag` annotation):

$ ./testcas.sh --category simple --test org.apereo.cas.authentication.handler.ConvertCasePrincipalNameTransformerTests

... which runs:

$ ./gradlew cleanTest testSimple --tests "org.apereo.cas.authentication.handler.ConvertCasePrincipalNameTransformerTests"

Unexpected result:

> Task :api:cas-server-core-api-configuration-model:testSimple FAILED
Started running test suite [Gradle Test Run :api:cas-server-core-api-configuration-model:testSimple] @ Sat Apr 03 11:31:45 CEST 2021

Results for test suite [Gradle Test Run :api:cas-server-core-api-configuration-model:testSimple]: SUCCESS @ Sat Apr 03 11:31:45 CEST 2021
(0 tests, 0 successes, 0 failures, 0 skipped)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':api:cas-server-core-api-configuration-model:testSimple'.

---

I tried to comment out various suspicious parts within the "cas/gradle/tests.gradle" file and also passing various switches to the Gradle build, but nothing worked so far.

So can anybody help with this? Until then, launching just selected tests from within IDEA, via its JUnits runner, seems to be the working way, and maybe that this could also be recommended for launching tests in an ad-hoc style in the CAS docs?

Pablo Vidaurri

unread,
Nov 9, 2021, 2:51:47 PM11/9/21
to CAS Community, p.bo...@centrum.cz
Did you find a solution to this? What happens for you when you run
   gradlew test
?

Petr Bodnár

unread,
Nov 10, 2021, 1:55:55 PM11/10/21
to CAS Community, Pablo Vidaurri, Petr Bodnár
No, I didn't. It looks like no one cares... I haven't checked against the latest version though.

If I run `gradlew test`, or rather `./gradlew cleanTest test -i`, I can see no tests are executed:

`````
...
> Task :api:cas-server-core-api:test SKIPPED
Skipping task ':api:cas-server-core-api:test' as task onlyIf is false.
...
`````

But that is probably no surprise, because "simple tests execution" is disabled in the "gradle/tests.gradle" file:

`````
test {
    enabled = false
    onlyIf = {
        false
    }
}
`````

Luckily, this is not a blocker for me right now.

Pablo Vidaurri

unread,
Nov 10, 2021, 2:06:34 PM11/10/21
to CAS Community, p.bo...@centrum.cz, Pablo Vidaurri
Interesting. The latest 6.3.7 currently under the 6.3 branch has neither gradel/tests.gradle nor testcas.sh .... I wonder what other files are missing.

Pablo Vidaurri

unread,
Nov 10, 2021, 2:19:08 PM11/10/21
to CAS Community, Pablo Vidaurri, p.bo...@centrum.cz
To clarify, I was looking in cas-template repo ... I do see mentioned files in regular cas repo

Pablo Vidaurri

unread,
Nov 10, 2021, 4:53:56 PM11/10/21
to CAS Community, Pablo Vidaurri, p.bo...@centrum.cz
Okay, I'm not a gradle expert yet but I came across this post and it helped solve my problem. Doing a scan as suggested, i was able to see that the junit platform was being downgraded by a plugin.

So after including in my dependencies:
testImplementation 'org.springframework.boot:spring-boot-starter-test'

and including a test block
test {
useJUnitPlatform {}
}

I also added this to my build.gradle which resolved my issue:
ext['junit-jupiter.version'] = '5.7.2'
Reply all
Reply to author
Forward
0 new messages