-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add JUnit support #107
Add JUnit support #107
Conversation
* Moved to its own plugin * Junit project extension
Last commit published: 0363b2c51f628e061a5232e364164142101d05f2. PR PublishingThe artifacts published by this PR:
Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #107' // https://github.com/neoforged/NeoGradle/pull/107
url 'https://prmaven.neoforged.net/NeoGradle/pr107'
content {
includeModule('net.neoforged.gradle', 'dsl-vanilla')
includeModule('net.neoforged.gradle', 'utils')
includeModule('net.neoforged.gradle', 'dsl-mixin')
includeModule('net.neoforged.gradle', 'common')
includeModule('net.neoforged.gradle', 'junit')
includeModule('net.neoforged.gradle', 'dsl-platform')
includeModule('net.neoforged.gradle', 'dsl-userdev')
includeModule('net.neoforged.gradle', 'mixin')
includeModule('net.neoforged.gradle.mixin', 'net.neoforged.gradle.mixin.gradle.plugin')
includeModule('net.neoforged.gradle', 'dsl-neoform')
includeModule('net.neoforged.gradle.common', 'net.neoforged.gradle.common.gradle.plugin')
includeModule('net.neoforged.gradle', 'neoform')
includeModule('net.neoforged.gradle.neoform', 'net.neoforged.gradle.neoform.gradle.plugin')
includeModule('net.neoforged.gradle', 'dsl-common')
includeModule('net.neoforged.gradle.junit', 'net.neoforged.gradle.junit.gradle.plugin')
includeModule('net.neoforged.gradle.userdev', 'net.neoforged.gradle.userdev.gradle.plugin')
includeModule('net.neoforged.gradle', 'vanilla')
includeModule('net.neoforged.gradle', 'platform')
includeModule('net.neoforged.gradle.platform', 'net.neoforged.gradle.platform.gradle.plugin')
includeModule('net.neoforged.gradle', 'userdev')
includeModule('net.neoforged.gradle.vanilla', 'net.neoforged.gradle.vanilla.gradle.plugin')
}
}
} |
How does this interact with running tests from IDEA directly (rather than through Gradle)? I'm assuming that it won't work, as FML/BootstrapLauncher expect environment variables and system properties to be present? |
If you run tests with the Gradle runner it will work fine in IDEA, if you run with the IntelliJ runner it won't, that's correct, and that's not really fixable. |
That's useful to know, thanks! Mostly just trying to compare with what I have now (I only need MC's Bootstrap for my existing tests, so can get away with doing less of a thorough job :)). |
platform/src/main/java/net/neoforged/gradle/platform/extensions/DynamicProjectExtension.java
Outdated
Show resolved
Hide resolved
junit/src/main/java/net/neoforged/gradle/junit/JUnitProjectPlugin.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
RunImpl junitRun = getOrCreateRun("junitTest", project, runtimeDefinition, runType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No if the user does not create one, then you should abort processing.
The userdev runtime will create a run named after the runtype, so creating another run here is redundant and wrong anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user is explicitly applying a special Neogradle junit plugin to get junit tests to work. That should get that set up without surprises and as seamlessly as possible, in my opinion.
Also: I do not think the userdev runtime creates runs based on runtypes automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it does not create them automatically. And even if it did, that would be a bad idea for the junit run type (and so would the user creating it normally). The run would generate run*
tasks, prepare*
tasks, and IDE run configurations which wouldn't work with JUnit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does not create the runs automatically. But your runtype should be configured enough that it should only need a:
runs {
unitTests{} //Or what ever the name of the unit test run type is.
}
To get the plugin to work. That is how all other run types are designed.
Please redesign this area.
dsl/common/src/main/groovy/net/neoforged/gradle/dsl/common/runs/type/RunType.groovy
Show resolved
Hide resolved
common/src/main/java/net/neoforged/gradle/common/util/run/RunsUtil.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
RunImpl junitRun = getOrCreateRun("junitTest", project, runtimeDefinition, runType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it does not create the runs automatically. But your runtype should be configured enough that it should only need a:
runs {
unitTests{} //Or what ever the name of the unit test run type is.
}
To get the plugin to work. That is how all other run types are designed.
Please redesign this area.
@marchermans The IntelliJ & Gradle unit test launchers are not runTypes, hence the comparison falls flat. We do not launch via a generated gradle task, nor do we launch via BootstrapLauncher here. |
Is superseded by #183 |
Add support for configuring JUnit run tasks.