Skip to content

Commit

Permalink
Gradle7 java11+ Support (#1003)
Browse files Browse the repository at this point in the history
* up to gradle 7 features, compiles and finishes now

* make multi-release to fix logger while running as jar in TestCube

* add support for Gradle 7 + adapt tests for Java 16

* jdk + build tools in readme, collapse option help
  • Loading branch information
lacinoire authored Oct 29, 2021
1 parent 5597805 commit d07b4b2
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ dspot/src/test/resources/mockito/log/
dspot/src/test/resources/multiple-pom/module-1/module-2-1/log/
dspot/src/test/resources/sample/log/
dspot/src/test/resources/test-projects/log/
dspot/src/test/resources/.gradle/
dspot/src/test/resources/gradle/
dspot/src/test/resources/mockito/.dspot_pom.xml
dspot/src/test/resources/multiple-pom/module-1/module-2-1/.dspot_pom.xml
dspot/src/test/resources/project-with-resources/.dspot_pom.xml
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ Amplify a specific test method from a specific test class
```bash
java -jar /path/to/dspot-LATEST-jar-with-dependencies.jar --absolute-path-to-project-root <path> --test my.package.TestClass --cases testMethod
```
### Command line options

### Command line options
<details>
<summary>Full list of command line options</summary>

```
Usage: eu.stamp_project.Main [-hvV] [--allow-path-in-assertions] [--clean] [--dev-friendly] [--example]
Expand Down Expand Up @@ -339,7 +341,9 @@ Usage: eu.stamp_project.Main [-hvV] [--allow-path-in-assertions] [--clean] [--de
Enable comment on amplified test: details steps of the amplification. Valid values: All,
Amplifier, Coverage, None. Default value: None
```


</details>

For options that take list, the used separator is a comma `,`, whatever the platform you use.

### Maven plugin usage
Expand Down Expand Up @@ -403,7 +407,7 @@ For now, there are three implementations of the Input Ampl Distributor:
* `SimpleInputAmplDistributor`: This distributor selects a fair number of amplified test method per Amplifier per test methods, if possible. The total budget is specified by the command line option ``--max-test-amplified`, and is the total number of amplified test methods to keep, _i.e._ it will be divide by the number of Amplifiers and by the number of test methods to be amplified.
Example: We have 2 Amplifiers. We apply them to 2 test methods. For each test methods, amplifiers generate 4 new test methods, totally 8 amplified test methods. If the budget is 6, it will select: 3 amplified test methods per amplifier, and 2 for one test method and 2 for the other.

#### Supported Features
#### Supported Test Frameworks

DSpot supports:

Expand All @@ -421,6 +425,19 @@ Please, do not amplify test classes that mix test frameworks (test methods in JU

If you have such test class, please amplify the different test framework separately.

#### Supported JDKs & Build Tools

DSpot runs with the following Java versions:

* Java 1.8
* Java 11
* Java 16 (used as JDK, not tested if it can support Java 16 language features)

It can amplify tests of projects built with:

* Maven 3.6
* Gradle 7

## Minimizing and Prettifying DSpot Amplified Test Cases
With the [DSpot Prettifier](dspot-prettifier) you can remove redundant assertions from your amplified test cases & give them more expressive names with the help of code2vec and context2vec.

Expand Down
4 changes: 2 additions & 2 deletions dspot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -248,7 +248,7 @@
<mainClass>eu.stamp_project.Main</mainClass>
</manifest>
<manifestEntries>
<Multi-Release>true</Multi-Release>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ void resetOriginalGradleBuildFile(String pathToRootOfProject) {
private String getPrintClasspathTask() {

return AmplificationHelper.LINE_SEPARATOR + AmplificationHelper.LINE_SEPARATOR +
"task " + WRITE_CLASSPATH_TASK + " << { " + AmplificationHelper.LINE_SEPARATOR +
" buildDir.mkdirs() " + AmplificationHelper.LINE_SEPARATOR +
" new File(buildDir, \"classpath.txt\").text = configurations.testCompile.asPath " + AmplificationHelper.LINE_SEPARATOR +
"task " + WRITE_CLASSPATH_TASK + " {" + AmplificationHelper.LINE_SEPARATOR +
" doLast { " + AmplificationHelper.LINE_SEPARATOR +
" buildDir.mkdirs() " + AmplificationHelper.LINE_SEPARATOR +
" new File(buildDir, \"classpath.txt\").text = configurations.testCompileClasspath.asPath " + AmplificationHelper.LINE_SEPARATOR +
" }" + AmplificationHelper.LINE_SEPARATOR +
"}" + AmplificationHelper.LINE_SEPARATOR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GradleAutomaticBuilderTest {

@Before
public void setUp() throws Exception {
assumeTrue("true".equals(System.getProperty("doIntegrationTests")));
//assumeTrue("true".equals(System.getProperty("doIntegrationTests")));
DSpotState.verbose = true;
cleanTestEnv();
LOGGER.debug("Test Set-up - Reading input parameters...");
Expand All @@ -72,7 +72,6 @@ public void tearDown() throws Exception {
LOGGER.debug("Test Tear-down complete.");
}

@Ignore
@Test
public void compile_whenCleanCompileTestTasksAreAppliedToDSpotTestExampleProject() throws Exception {
LOGGER.info("Starting Gradle Automatic Builder compile() test...");
Expand All @@ -82,7 +81,6 @@ public void compile_whenCleanCompileTestTasksAreAppliedToDSpotTestExampleProject
LOGGER.info("Gradle Automatic Builder compile() test complete.");
}

@Ignore
@Test
public void buildClasspath_whenAppliedToDSpotTestExampleProject() throws Exception {
LOGGER.info("Starting Gradle Automatic Builder buildClasspath() test...");
Expand All @@ -100,7 +98,6 @@ public void buildClasspath_whenAppliedToDSpotTestExampleProject() throws Excepti
LOGGER.info("Gradle Automatic Builder buildClasspath() test complete.");
}

@Ignore
@Test
public void runPit_whenNoTestClassIsSpecified() throws Exception {
LOGGER.info("Starting Gradle Automatic Builder runPit() test when no test class is specified...");
Expand All @@ -112,7 +109,7 @@ public void runPit_whenNoTestClassIsSpecified() throws Exception {
LOGGER.info("Gradle Automatic Builder runPit() test complete when no test class is specified.");
}

@Ignore

@Test
public void runPit_whenTestClassIsSpecified() throws Exception {
LOGGER.info("Starting Gradle Automatic Builder runPit() test when a test class is specified...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public void tearDown() throws Exception {
LOGGER.debug("Test Tear-down complete.");
}

@Ignore
@Test
public void runPit_whenAllDescartesMutatorsAreSpecified() throws Exception {
LOGGER.info("Starting Gradle Automatic Builder runPit() test when a test class is specified...");
Expand Down
2 changes: 1 addition & 1 deletion dspot/src/test/resources/sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>

Expand Down
6 changes: 3 additions & 3 deletions dspot/src/test/resources/test-projects/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}

dependencies {
compile 'org.apache.logging.log4j:log4j-api:2.8.2'
compile 'org.apache.logging.log4j:log4j-core:2.8.2'
testCompile 'junit:junit:4.12'
implementation 'org.apache.logging.log4j:log4j-api:2.8.2'
implementation 'org.apache.logging.log4j:log4j-core:2.8.2'
testImplementation 'junit:junit:4.12'
}

0 comments on commit d07b4b2

Please sign in to comment.