Skip to content

Commit 77eef45

Browse files
committed
Updated unit test project based on new marklogic-unit-test release
1 parent e0e9129 commit 77eef45

File tree

6 files changed

+40
-104
lines changed

6 files changed

+40
-104
lines changed

build.gradle

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id "maven-publish"
44
id "signing"
55

6-
id "com.github.jk1.dependency-license-report" version "1.3"
6+
id "com.github.jk1.dependency-license-report" version "1.17"
77
id "com.gradle.plugin-publish" version "0.15.0"
88
id "java-gradle-plugin"
99

@@ -19,11 +19,7 @@ targetCompatibility = "8"
1919

2020
repositories {
2121
mavenLocal() // Used only for local development
22-
2322
mavenCentral()
24-
25-
// Needed for marklogic-unit-test-client
26-
jcenter()
2723
}
2824

2925
dependencies {
@@ -34,7 +30,7 @@ dependencies {
3430
implementation "com.marklogic:marklogic-data-movement-components:2.3.0"
3531
implementation "commons-io:commons-io:2.8.0"
3632

37-
compileOnly "com.marklogic:marklogic-unit-test-client:1.0.0"
33+
compileOnly "com.marklogic:marklogic-unit-test-client:1.1.0"
3834

3935
testImplementation localGroovy()
4036
testImplementation gradleTestKit()

examples/unit-test-project/README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ include this by default (not every ml-gradle user will use marklogic-unit-test),
99

1010
buildscript {
1111
repositories {
12-
jcenter()
12+
mavenCentral()
1313
}
1414
dependencies {
15-
classpath "com.marklogic:marklogic-unit-test-client:1.0.0"
15+
classpath "com.marklogic:marklogic-unit-test-client:1.1.0"
1616
}
1717
}
1818

1919
Next, the marklogic-unit-test framework is depended on and installed as an "mlBundle" dependency (the "mlBundle" configuration
2020
is a feature of ml-gradle for depending on packages of MarkLogic modules):
2121

2222
repositories {
23-
jcenter()
23+
mavenCentral()
2424
}
2525
2626
dependencies {
27-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.0.0"
27+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.1.0"
2828
}
2929

3030
## Running unit tests
@@ -34,32 +34,35 @@ determine which MarkLogic app server to connect to - see below for how to custom
3434

3535
First, deploy the application:
3636

37-
gradle mlDeploy
37+
./gradlew mlDeploy
3838

3939
This will deploy the application along with the marklogic-unit-test modules.
4040

4141
Then, run the tests:
4242

43-
gradle mlUnitTest
43+
./gradlew mlUnitTest
4444

4545
Two tests are run, and one should fail, so you can see what a failed test looks like.
4646

4747
This project includes the Gradle Java plugin, which allows you to run tests under src/test/java. This project includes
48-
an example of a JUnit Parameterized test that invokes each marklogic-unit-test module separately - you can try it like this:
48+
an example of a test that invokes each marklogic-unit-test module separately - you can try it like this:
4949

50-
gradle test
50+
./gradlew test
5151

52-
Again, two tests will run, and one will intentionally fail. The Parameterized test can be run in an IDE as well, allowing
53-
you to take advantage of your IDE's support for JUnit tests.
52+
Again, two tests will run, and one will intentionally fail. The test can be run in an IDE as well, allowing
53+
you to take advantage of your IDE's support for JUnit tests. The test depends on the marklogic-junit5 library from the
54+
marklogic-unit-test project. This library provides support for writing JUnit 5 tests, including running all of your
55+
marklogic-unit-test modules. See [the marklogic-junit5 project](https://github.com/marklogic-community/marklogic-unit-test/tree/master/marklogic-junit5)
56+
for more information.
5457

5558
You can also access the marklogic-unit-test REST endpoints directly:
5659

57-
- List the tests - http://localhost:8135/v1/resources/marklogic-unit-test
58-
- Run a test suite - http://localhost:8135/v1/resources/marklogic-unit-test?rs:func=run&rs:suite=My%20Tests
60+
- List the tests - http://localhost:8015/v1/resources/marklogic-unit-test
61+
- Run a test suite - http://localhost:8015/v1/resources/marklogic-unit-test?rs:func=run&rs:suite=My%20Tests
5962

6063
And you can run the original UI test runner by going to:
6164

62-
- http://localhost:8135/test/default.xqy
65+
- http://localhost:8015/test/default.xqy
6366

6467
## Configuring which server mlUnitTest connects to
6568

examples/unit-test-project/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
buildscript {
22
repositories {
3-
// Still need jcenter until marklogic-unit-test is published to Maven Central
4-
jcenter()
53
mavenCentral()
64
mavenLocal()
75
}
@@ -16,13 +14,16 @@ apply plugin: "com.marklogic.ml-gradle"
1614

1715
repositories {
1816
mavenCentral()
19-
jcenter()
17+
mavenLocal()
2018
}
2119

2220
dependencies {
2321
mlBundle "com.marklogic:marklogic-unit-test-modules:${marklogicUnitTestVersion}"
2422

2523
// For running marklogic-unit-test tests via JUnit
26-
testImplementation "com.marklogic:marklogic-unit-test-client:${marklogicUnitTestVersion}"
27-
testImplementation "junit:junit:4.12"
24+
testImplementation "com.marklogic:marklogic-junit5:${marklogicUnitTestVersion}"
25+
}
26+
27+
test {
28+
useJUnitPlatform()
2829
}

examples/unit-test-project/gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
mlGradleVersion=4.3.0
2-
marklogicUnitTestVersion=1.0.0
1+
mlGradleVersion=4.3.0-SNAPSHOT
2+
marklogicUnitTestVersion=1.1.0
33

44
mlHost=localhost
55
mlAppName=unit-test-example
6-
mlRestPort=8134
6+
mlRestPort=8014
77

88
# It's recommend to have two REST servers - one for the app, and one for running tests, which will point to a separate
99
# content database as well
1010

11-
mlTestRestPort=8135
11+
mlTestRestPort=8015
1212
mlUsername=admin
1313
mlPassword=admin
1414

examples/unit-test-project/src/test/java/example/ParameterizedTest.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package example;
2+
3+
import com.marklogic.junit5.spring.MarkLogicUnitTestsTest;
4+
5+
/**
6+
* Example of running each test module as a separate JUnit test. The parent class handles all the work, which includes
7+
* reading config from gradle.properties and gradle-local.properties. This class is needed though so that JUnit has
8+
* something it can find and run in the test source tree.
9+
*/
10+
public class RunUnitTestsTest extends MarkLogicUnitTestsTest {
11+
12+
}

0 commit comments

Comments
 (0)