Skip to content

Commit 033d10b

Browse files
Improving the project landing page (#73)
Adding instructions for getting started using marklogic-unit-test.
1 parent 549cb4a commit 033d10b

File tree

1 file changed

+87
-9
lines changed

1 file changed

+87
-9
lines changed

README.md

100644100755
Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,102 @@
33
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
# Testing MarkLogic
55

6-
marklogic-unit-test is an [ml-gradle bundle](https://github.com/marklogic-community/ml-gradle/wiki/Bundles) that allows
7-
a project to test MarkLogic code. With one import a project immediately has access to:
6+
marklogic-unit-test is a testing framework that allows a project to test MarkLogic code. With one import a project
7+
immediately has access to:
88

99
1. A framework for writing and running MarkLogic unit tests, including several built in assertion functions
1010
1. A UI for viewing and running unit tests entirely within MarkLogic
1111
1. A REST endpoint to run and report unit tests with other tools
1212

13-
Testing MarkLogic from a Java project is made easy with marklogic-junit:
13+
Testing MarkLogic from a Java project is made easy with marklogic-junit5:
1414

1515
1. Write MarkLogic tests entirely from Java
16-
1. Easily integrate MarkLogic unit tests into your favorite Java testing frameworks
16+
1. Easily integrate MarkLogic unit tests into your JUnit 5 project
1717

1818
# Start using marklogic-unit-test
1919

20-
If you'd like to use marklogic-unit-test check out this
21-
[ml-gradle example project](https://github.com/marklogic-community/ml-gradle/tree/dev/examples/unit-test-project).
22-
You can use that project's build.gradle file as an example of how to use marklogic-unit-test in your own project.
20+
MarkLogic unit test can easily be integrated into your project as an [ml-bundle](https://github.com/marklogic-community/ml-gradle/wiki/Bundles).
21+
The following steps will configure a project to import and use marklogic-unit-tests.
22+
23+
If you'd like to skip straight to the end, you can check out a [working example project](https://github.com/marklogic-community/ml-gradle/tree/dev/examples/unit-test-project).
24+
You can use that project's `build.gradle` file as an example of how to use marklogic-unit-test in your own project.
25+
26+
### Add marklogic-unit-test to `build.gradle`
27+
28+
```groovy
29+
buildscript {
30+
repositories {
31+
jcenter()
32+
mavenLocal()
33+
}
34+
dependencies {
35+
classpath "com.marklogic:marklogic-unit-test-client:1.0.beta"
36+
classpath "com.marklogic:ml-gradle:3.14.0"
37+
}
38+
}
39+
40+
apply plugin: "com.marklogic.ml-gradle"
41+
42+
repositories {
43+
jcenter()
44+
}
45+
46+
dependencies {
47+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.0.beta"
48+
}
49+
```
50+
51+
### Add Test Properties to `gradle.properties`
52+
53+
```properties
54+
// Settings for any ml-gradle project
55+
mlHost=localhost // Assuming local development
56+
mlAppName=my-app // Application name, defaults to my-app
57+
mlRestPort=8003 // Application Port, defaults to 8003
58+
mlUsername= // Username used to manage MarkLogic
59+
mlPassword= // Password used to manage MarkLogic
60+
61+
62+
// Settings specific to marklogic-unit-test
63+
mlTestRestPort=8004 // Testing port, view and run tests from this port
64+
65+
// ml-gradle supports deploying to multiple environments (https://github.com/marklogic-community/ml-gradle/wiki/Configuring-ml-gradle#environment-based-properties).\
66+
// Add the following line to gradle-{env}.properties files for which you would like to deploy the tests. Typically
67+
// tests are only deployed to environments that execute automated tests, like local development and CI environments.
68+
mlModulePaths=src/main/ml-modules,src/test/ml-modules
69+
```
70+
71+
### Deploy tests using ml-gradle
72+
73+
Now that the environment is configured to load tests and setup a test application servier its time to deploy everything.
74+
```sh
75+
./gradlew mlDeploy
76+
```
77+
78+
To enable quicker feedback between code updates and automated test runs, use the mlWatch task to automatically deploy
79+
changes to MarkLogic
80+
```sh
81+
./gradlew mlWatch
82+
```
83+
84+
### Access marklogic-unit-test UI
85+
86+
Open a web browser to http://localhost:8004/test/. This is where tests are selected, run, and results are displayed.
87+
88+
If this is a project that's new to marklogic-unit-tests no test suites are displayed because there are no tests.
89+
90+
### Creating a test suite
91+
92+
Creating test suites is easy using the mlGenerateUnitTestSuite gradle task. Run the following to setup a sample test suite:
93+
```sh
94+
./gradlew mlGenerateUnitTestSuite
95+
```
96+
97+
Now a new test suite has been generated in `src/test/ml-modules/root/test/suites` called `SampleTestSuite`.
98+
99+
If `mlWatch` is being used, refreshing the web browser at http://localhost:8004/test/ will now show the newly created
100+
`SampleTestSuite`. The suite can be run using the Run Tests button at the top or bottom of the page.
23101

24102
# Start using marklogic-junit
25-
Check out the [marklogic-junit sub-project](https://github.com/marklogic-community/marklogic-unit-test/tree/master/marklogic-junit)
26-
to get started using marklogic-junit.
103+
Check out the [marklogic-junit5 sub-project](https://github.com/marklogic-community/marklogic-unit-test/tree/master/marklogic-junit5)
104+
to get started using marklogic-junit5.

0 commit comments

Comments
 (0)