This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Need an example for multiple tests adding up to 100 #56
Comments
An update: |
I'm no Gradle expert, but I had a similar issue in the past and used the task test_constructor (type: Test) {
filter.includeTestsMatching "ConstructorTest"
}
// other test tasks here
// ....
sourceSets {
if (project.gradle.startParameter.taskNames.contains("test_constructor")) {
test.java.exclude '**/LotsOfGuessesTest*'
test.java.exclude '**/TestMain*'
test.java.exclude '**/TestMainLoop*'
sourceSets.main.java.excludes = ['Main*']
}
else if (project.gradle.startParameter.taskNames.contains("test_loser")) {
test.java.exclude '**/TestMain*'
test.java.exclude '**/TestMainLoop*'
sourceSets.main.java.excludes = ['Main*']
}
else if (project.gradle.startParameter.taskNames.contains("test_lots_of_guesses")) {
test.java.exclude '**/TestMain*'
test.java.exclude '**/TestMainLoop*'
sourceSets.main.java.excludes = ['Main*']
}
else if (project.gradle.startParameter.taskNames.contains("test_main")) {
test.java.exclude '**/TestMainLoop*'
}
} Then, in my autograding.json file I call the tests one by one. To call the "constructor" test from the Gradle snippet above for instance, the test is: {
"name": "Test constructors",
"setup": "",
"run": "timeout 60 gradle test_constructor",
"input": "",
"output": "",
"comparison": "included",
"timeout": 1,
"points": 20
} I hope this helps. |
I'll try that, thanks Steve!
…On Thu, Nov 3, 2022 at 9:00 PM Steve Bitner ***@***.***> wrote:
I'm no Gradle expert, but I had a similar issue in the past and used the
sourceSets attribute to exclude all classes that were not required for a
given test. For example:
task test_constructor (type: Test) {
filter.includeTestsMatching "ConstructorTest"
}
// other test tasks here// ....
sourceSets {
if (project.gradle.startParameter.taskNames.contains("test_constructor")) {
test.java.exclude '**/LotsOfGuessesTest*'
test.java.exclude '**/TestMain*'
test.java.exclude '**/TestMainLoop*'
sourceSets.main.java.excludes = ['Main*']
}
else if (project.gradle.startParameter.taskNames.contains("test_loser")) {
test.java.exclude '**/TestMain*'
test.java.exclude '**/TestMainLoop*'
sourceSets.main.java.excludes = ['Main*']
}
else if (project.gradle.startParameter.taskNames.contains("test_lots_of_guesses")) {
test.java.exclude '**/TestMain*'
test.java.exclude '**/TestMainLoop*'
sourceSets.main.java.excludes = ['Main*']
}
else if (project.gradle.startParameter.taskNames.contains("test_main")) {
test.java.exclude '**/TestMainLoop*'
}
}
Then, in my autograding.json file I call the tests one by one. To call the
"constructor" test from the Gradle snippet above for instance, the test is:
{
"name": "Test constructors",
"setup": "",
"run": "timeout 60 gradle test_constructor",
"input": "",
"output": "",
"comparison": "included",
"timeout": 1,
"points": 20
}
I hope this helps.
—
Reply to this email directly, view it on GitHub
<#56 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH66V74TLPPDZDL4TUDT6OTWGQDVHANCNFSM542U26ZQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
I work with Java and Gradle. I followed the example repository .
I tried it myself, but the Action runs all 3 tests as a single test, 3 times.
So one broken test causes 0 points total.
Can you give an example that works? maybe improve on the example repository.
My assignment:
https://classroom.github.com/classrooms/83712254/assignments/olympics
The text was updated successfully, but these errors were encountered: