-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testCompileOnly extends compileOnly for Whitebox Test Suites
Resolves #51
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/groovy/org/gradlex/javamodule/testing/test/CoreFunctionailtyTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.gradlex.javamodule.testing.test | ||
|
||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.gradlex.javamodule.testing.test.fixture.GradleBuild | ||
import spock.lang.Specification | ||
|
||
class CoreFunctionailtyTest extends Specification { | ||
|
||
@Delegate | ||
GradleBuild build = new GradleBuild() | ||
|
||
def "testCompileOnly extends compileOnly for whitebox test suites"() { | ||
given: | ||
appBuildFile << ''' | ||
javaModuleTesting.classpath(testing.suites["test"]) | ||
dependencies { | ||
compileOnly("jakarta.servlet:jakarta.servlet-api:6.1.0") | ||
} | ||
''' | ||
file("app/src/main/java/org/example/app/ServletImpl.java") << ''' | ||
package org.example.app; | ||
public abstract class ServletImpl implements jakarta.servlet.Servlet { } | ||
''' | ||
file("app/src/test/java/org/example/app/test/ServletMock.java") << ''' | ||
package org.example.app.test; | ||
public abstract class ServletMock extends org.example.app.ServletImpl { } | ||
''' | ||
appModuleInfoFile << ''' | ||
module org.example.app { | ||
requires static jakarta.servlet; | ||
} | ||
''' | ||
|
||
when: | ||
def result = runner('compileTestJava').build() | ||
|
||
then: | ||
result.task(':app:compileTestJava').outcome == TaskOutcome.SUCCESS | ||
} | ||
} |