blob: 0f09aa9cbcfe357dcc2bf6c540ec2ca231858565 [file] [log] [blame]
Alex Volanis7004a612018-01-24 10:30:13 -05001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20// Following Gradle best practices to keep build logic organized
21
22// Bundle the test classes in a JAR for other Ant based builds
23task testJar(type: Jar, group: 'Build') {
24 description = 'Assembles a jar archive containing the test classes.'
25 project.test.dependsOn it
26
27 classifier 'test'
28 from sourceSets.test.output
29}
30
31// ----------------------------------------------------------------------------
32// Unit test tasks and configurations
33
34// Help the up to date algorithm to make these tests done
35ext.markTaskDone = { task ->
36 def buildFile = file("$buildDir/${task.name}.flag")
37 task.inputs.files task.classpath
38 task.outputs.file buildFile
39 task.doLast {
40 buildFile.text = 'Passed!'
41 }
42}
43
44task deprecatedEqualityTest(type: JavaExec, group: 'Verification') {
45 description = 'Run the non-JUnit test suite '
46 classpath = sourceSets.test.runtimeClasspath
47 main 'org.apache.thrift.test.EqualityTest'
48 markTaskDone(it)
49}
50
51task deprecatedJavaBeansTest(type: JavaExec, group: 'Verification') {
52 description = 'Run the non-JUnit test suite '
53 classpath = sourceSets.test.runtimeClasspath
54 main 'org.apache.thrift.test.JavaBeansTest'
55 markTaskDone(it)
56}
57
58// Main Unit Test task configuration
59test {
60 description="Run the full test suite"
61 dependsOn deprecatedEqualityTest, deprecatedJavaBeansTest
62
63 // Allow repeating tests even after successful execution
64 if (project.hasProperty('rerunTests')) {
65 outputs.upToDateWhen { false }
66 }
67
68 include '**/Test*.class'
69 exclude '**/Test*\$*.class'
70
Jiayu Liu0c9c9df2022-05-06 03:30:52 +080071 // https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle
72 useJUnitPlatform() {
73 // https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution
74 systemProperty("junit.jupiter.execution.parallel.enabled", "true")
75 systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
76 systemProperty("junit.jupiter.execution.parallel.mode.classes.default", "concurrent")
77 }
78
Alex Volanis7004a612018-01-24 10:30:13 -050079 maxHeapSize = '512m'
Alex Volanis7004a612018-01-24 10:30:13 -050080
81 systemProperties = [
82 'build.test': "${compileTestJava.destinationDir}",
83 'test.port': "${testPort}",
Jiayu Liueac51032022-03-11 04:55:13 +010084 'javax.net.ssl.trustStore': "${projectDir}/src/crossTest/resources/.truststore",
Alex Volanis7004a612018-01-24 10:30:13 -050085 'javax.net.ssl.trustStorePassword': 'thrift',
Jiayu Liueac51032022-03-11 04:55:13 +010086 'javax.net.ssl.keyStore': "${projectDir}/src/crossTest/resources/.keystore",
Alex Volanis7004a612018-01-24 10:30:13 -050087 'javax.net.ssl.keyStorePassword': 'thrift'
88 ]
89}