Tests will be run using the command ./gradlew clean test
.
Make sure that the package structure of your test classes is equivalent to the package structure of your base and solution repository. Otherwise, during the test run Gradle will not be able to find the imported classes in your test files.
In order to use classes from the template or solution repository in a test case, you have to add the respective repository files as a dependency to the test project. Follow this description for IntelliJ:
- Open the Test-Project first
- Select
File
->New
->Module from Existing Source
. Then choose the template project root folder. Select the optionImport module from external model
andGradle
and pressFinish
. - Repeat the previous step for the Solution-Project.
- Uncomment and edit the following line in
settings.gradle
within the Test-Project:includeBuild('/path/to/repository-exercise')
orincludeBuild('/path/to/repository-solution')
depending on which project you want to use the source files for executing the test cases. The path can be given relative to the test project directory (e.g.,../repository-solution
). - Inside the
dependencies
-block in thebuild.gradle
inside the Test-Project, uncomment one of the lines:testImplementation(':test1')
ortestImplementation(':test1-Solution')
depending on which project you want to use the source files for executing the test cases. - Change the
assignmentSrcDir
variable inbuild.gradle
to the correspondingsrc/
directory within the template or solution repository (e.g.,../repository-solution/src/
).
Note:
The described changes to the build.gradle
and settings.gradle
files must
not be pushed to the remote repository as they can only be used for editing
all three projects in the local IDE.
In case you have enabled sequential test runs when creating the exercise a special folder structure of the test repository is used to differentiate structural and behavior tests:
- Structural test files must be placed in the folder
structural
. - Behavior test files must be placed in the folder
behavior
.
Files in other folders will not be executed!
The build.gradle
contains dependencies for the execution of static code
analysis, if the option is active for this programming exercise.