Skip to content

Commit 4681ba2

Browse files
authored
Merge pull request #200 from marklogic-community/release/1.4.0
Release/1.4.0
2 parents cceb979 + 4f5697f commit 4681ba2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1226
-628
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ subprojects {
44
apply plugin: "signing"
55

66
group = "com.marklogic"
7-
version = "1.3.0"
7+
version = "1.4.0"
88

99
java {
1010
sourceCompatibility = 1.8
@@ -16,6 +16,10 @@ subprojects {
1616

1717
// For local development
1818
mavenLocal()
19+
20+
maven {
21+
url "https://nexus.marklogic.com/repository/maven-snapshots/"
22+
}
1923
}
2024

2125
dependencies {

docs/assertion-functions.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
title: Assertion functions
4-
nav_order: 6
4+
nav_order: 7
55
permalink: /docs/assertions
66
---
77

@@ -47,14 +47,15 @@ assert-same-values($expected as item()*, $actual as item()*)
4747
assert-same-values($expected as item()*, $actual as item()*, $message as xs:string*)
4848
assert-throws-error($function as xdmp:function)
4949
assert-throws-error($function as xdmp:function, $error-code as xs:string?)
50-
assert-throws-error($function as xdmp:function, $param1 as item()*, $error-code as xs:string?)
51-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $error-code as xs:string?)
52-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $error-code as xs:string?)
53-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 as item()*, $error-code as xs:string?)
54-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 as item()*, $param5 as item()*, $error-code as xs:string?)
55-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 as item()*, $param5 as item()*, $param6 as item()*, $error-code as xs:string?)
50+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $error-code as xs:string?)
51+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $error-code as xs:string?)
52+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $error-code as xs:string?)
53+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 as item()*, $error-code as xs:string?)
54+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 as item()*, $param5 as item()*, $error-code as xs:string?)
55+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 as item()*, $param5 as item()*, $param6 as item()*, $error-code as xs:string?)
5656
assert-throws-error-with-message($function as xdmp:function, $expected-error-code as xs:string, $expected-message as xs:string)
5757
assert-throws-error-with-message($function as xdmp:function, $expected-error-code as xs:string, $expected-message as xs:string, $message as xs:string*)
5858
assert-true($conditions as xs:boolean*)
5959
assert-true($conditions as xs:boolean*, $message as xs:string?)
6060
```
61+
- Note: Functions marked with * are deprecated and will be removed in the 2.0 release of marklogic-unit-test. Please use the assert-throws-error function that requires a function to be passed to it.

docs/debugging-tests.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
layout: default
3+
title: Debugging tests
4+
nav_order: 5
5+
permalink: /docs/debugging
6+
---
7+
8+
Like all unit testing frameworks, marklogic-unit-test is intended to speed up the cycle of developing, testing, and
9+
fixing code. A critical aspect of that is understanding why a test failed and how to fix it. This page provides
10+
guidance on how you can write your tests to ensure they can be easily debugged by any member of your development
11+
team.
12+
13+
## Development setup
14+
15+
Before looking at how to write tests, you should ensure that you can change your application code and test the
16+
changes as quickly as possible. As mentioned in the [Getting started guide](/docs), ml-gradle supports
17+
[watching for module changes](https://github.com/marklogic/ml-gradle/wiki/Watching-for-module-changes) so that when
18+
you modify either an application module file or test module file, the file will be immediately loaded into your
19+
application's modules database. This allows you to test your changes as quickly as possible.
20+
21+
To enable this, simply run the following Gradle task in its own terminal window:
22+
23+
./gradlew -i mlWatch
24+
25+
The Gradle "-i" flag - for info-level logging - results in each modified file being logged when it is loaded into
26+
MarkLogic.
27+
28+
## Test assertion messages
29+
30+
Each [assertion function](/docs/assertions) in marklogic-unit-test supports an assertion message as its final argument.
31+
These are recommended for when the intent of an assertion is not readily apparent from the two values being compared.
32+
33+
For example, consider the following assertion:
34+
35+
const actual = someLib.something();
36+
test.assertEqual(3, actual);
37+
38+
If that assertion fails because "actual" has a value of 2, marklogic-unit-test will throw the following error:
39+
40+
expected: 3 actual: 2 (ASSERT-EQUAL-FAILED)
41+
42+
However, this doesn't explain why "3" is the expected value. The optional 3rd argument in `test.assertEqual`
43+
provides a test developer with a chance to explain why the value is expected - e.g.:
44+
45+
const actual = someLib.something();
46+
test.assertEqual(3, actual, "Due to such-and-such reason, 3 should be returned");
47+
48+
The "such-and-such reason" would of course be replaced with a meaningful explanation in your test.
49+
marklogic-unit-test will then include this message in the failure message:
50+
51+
Due to such-and-such reason, 3 should be returned; expected: 3 actual: 2 (ASSERT-EQUAL-FAILED)
52+
53+
## Using log statements
54+
55+
While tools such as [mlxprs](https://github.com/marklogic/mlxprs) exist to leverage the debugging capabilities within
56+
MarkLogic, you may often find it helpful to include log statements both in your application module and in your test
57+
module. These can log the value of certain variables that are not returned by the function being tested but whose
58+
values provide insight into how the application code is behaving.
59+
60+
For JavaScript code, use the following:
61+
62+
const value = someLib.something();
63+
console.log("The value", value);
64+
65+
And for XQuery code, use the following:
66+
67+
let $value := someLib:something()
68+
let $_ := xdmp:log(("The value", $value))
69+
70+
You can add these statements to your tests as well.
71+
72+
Log messages will then appear in the MarkLogic log file named "PORT_ErrorLog.txt", where "PORT" is the port number
73+
of the MarkLogic app server that you are running the tests against.
74+
75+
## Examining the Gradle test report
76+
77+
When running tests via Gradle - either via `./gradlew test` or `./gradlew mlUnitTest` - one or more test failures will
78+
result in the task failing with the location of the test report being logged. The test report allows you to see details
79+
on each test, including the failed assertion message and stacktrace for each failed test.
80+
81+
When running `./gradlew test`, the test report will be available at "build/reports/tests/tests/index.html". You can
82+
open this file in a web browser to see the results; it is recommended to keep that window open and simply refresh it
83+
after re-running the Gradle `test` task.
84+
85+
When running `./gradlew mlUnitTest`, the test report is a set of JUnit-formatted XML files available at
86+
"build/test-results/marklogic-unit-test". This approach does not result in an HTML web page that can be viewed in a web
87+
browser, but each XML file will contain the results for the tests in a particular suite, including the failed assertion
88+
messages and stacktrace for each failed test.
89+

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ adding the following configuration to the project's `build.gradle` file:
3030

3131
```
3232
dependencies {
33-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
33+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0"
3434
}
3535
```
3636

@@ -49,7 +49,7 @@ buildscript {
4949
mavenCentral()
5050
}
5151
dependencies {
52-
classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
52+
classpath "com.marklogic:marklogic-unit-test-client:1.4.0"
5353
}
5454
}
5555
```

docs/loading-test-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
title: Loading test data
4-
nav_order: 5
4+
nav_order: 6
55
permalink: /docs/loading
66
---
77

docs/running-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildscript {
1919
mavenCentral()
2020
}
2121
dependencies {
22-
classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
22+
classpath "com.marklogic:marklogic-unit-test-client:1.4.0"
2323
}
2424
}
2525
```

examples/getting-started/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
6+
classpath "com.marklogic:marklogic-unit-test-client:1.4.0"
77
}
88
}
99

@@ -17,5 +17,5 @@ repositories {
1717
}
1818

1919
dependencies {
20-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
20+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0"
2121
}

examples/test-examples/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
6+
classpath "com.marklogic:marklogic-unit-test-client:1.4.0"
77
}
88
}
99

1010
plugins {
1111
id "net.saliman.properties" version "1.5.2"
12-
id "com.marklogic.ml-gradle" version "4.5.2"
12+
id "com.marklogic.ml-gradle" version "4.6.0"
1313
}
1414

1515
repositories {
1616
mavenCentral()
1717
}
1818

1919
dependencies {
20-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
20+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0"
2121
}

marklogic-junit5/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plugins {
44

55
dependencies {
66
api project(":marklogic-unit-test-client")
7-
api "com.marklogic:ml-javaclient-util:4.5.0"
7+
api "com.marklogic:ml-javaclient-util:4.6.0"
88
api "org.jdom:jdom2:2.0.6.1"
9-
api "org.junit.jupiter:junit-jupiter:5.9.2"
10-
api "org.springframework:spring-context:5.3.24"
11-
api "org.springframework:spring-test:5.3.24"
12-
api "com.fasterxml.jackson.core:jackson-databind:2.14.1"
9+
api "org.junit.jupiter:junit-jupiter:5.10.0"
10+
api "org.springframework:spring-context:5.3.29"
11+
api "org.springframework:spring-test:5.3.29"
12+
api "com.fasterxml.jackson.core:jackson-databind:2.15.2"
1313
api 'org.slf4j:slf4j-api:1.7.36'
1414

1515
implementation "jaxen:jaxen:2.0.0"

marklogic-junit5/examples/simple-ml-gradle/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Next, add the following dependencies:
3636
dependencies {
3737
// existing dependencies
3838
39-
testImplementation "com.marklogic:marklogic-junit5:1.3.0"
39+
testImplementation "com.marklogic:marklogic-junit5:1.4.0"
4040
4141
// Forcing Spring to use logback instead of commons-logging
4242
testImplementation "ch.qos.logback:logback-classic:1.3.5"
@@ -107,8 +107,8 @@ You'll still be able to leverage all of the testing support in AbstractMarkLogic
107107
If you'd like to write and execute marklogic-unit-test test modules, add the following to your build.gradle file as well (grab
108108
the latest version for both dependencies):
109109

110-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
111-
testImplementation "com.marklogic:marklogic-unit-test-client:1.3.0"
110+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0"
111+
testImplementation "com.marklogic:marklogic-unit-test-client:1.4.0"
112112

113113
In addition, add the following to gradle.properties so that you can store test modules in a directory separate from
114114
your application modules:

0 commit comments

Comments
 (0)