Skip to content

Commit 04d9601

Browse files
authored
Merge branch 'master' into dependabot/bundler/docs/commonmarker-0.23.10
2 parents 9adb067 + 0819ec0 commit 04d9601

Some content is hidden

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

51 files changed

+1348
-631
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ out
1010
marklogic-unit-test-client/bin/
1111
gradle-local.properties
1212
.vscode
13+
bin

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/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ _site
33
.jekyll-cache
44
.jekyll-metadata
55
vendor
6+
.ruby-version

docs/Gemfile.lock

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ GEM
210210
jekyll-feed (~> 0.9)
211211
jekyll-seo-tag (~> 2.1)
212212
minitest (5.19.0)
213-
nokogiri (1.15.3-arm64-darwin)
213+
nokogiri (1.16.5-arm64-darwin)
214+
racc (~> 1.4)
215+
nokogiri (1.16.5-x86_64-linux)
214216
racc (~> 1.4)
215217
nokogiri (1.15.3-x86_64-linux)
216218
racc (~> 1.4)
@@ -220,11 +222,12 @@ GEM
220222
pathutil (0.16.2)
221223
forwardable-extended (~> 2.6)
222224
public_suffix (4.0.7)
223-
racc (1.7.1)
225+
racc (1.7.3)
224226
rb-fsevent (0.11.2)
225227
rb-inotify (0.10.1)
226228
ffi (~> 1.0)
227-
rexml (3.2.6)
229+
rexml (3.3.6)
230+
strscan
228231
rouge (3.26.0)
229232
ruby2_keywords (0.0.5)
230233
rubyzip (2.3.2)
@@ -239,6 +242,7 @@ GEM
239242
faraday (>= 0.17.3, < 3)
240243
simpleidn (0.2.1)
241244
unf (~> 0.1.4)
245+
strscan (3.1.0)
242246
terminal-table (1.8.0)
243247
unicode-display_width (~> 1.1, >= 1.1.1)
244248
typhoeus (1.4.0)
@@ -253,6 +257,7 @@ GEM
253257

254258
PLATFORMS
255259
arm64-darwin-21
260+
arm64-darwin-23
256261
x86_64-linux
257262

258263
DEPENDENCIES

docs/_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins:
55

66
heading_anchors: true
77

8+
logo: "/assets/ProgressMarkLogic_PrimaryLogo_Stacked.svg"
9+
810
# Aux links for the upper right navigation
911
aux_links:
1012
"marklogic-community/marklogic-unit-test":

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
---
66

77
The list below captures the assertion functions available in the marklogic-unit-test `/test/test-helper.xqy` module.
@@ -46,14 +46,15 @@ assert-same-values($expected as item()*, $actual as item()*)
4646
assert-same-values($expected as item()*, $actual as item()*, $message as xs:string*)
4747
assert-throws-error($function as xdmp:function)
4848
assert-throws-error($function as xdmp:function, $error-code as xs:string?)
49-
assert-throws-error($function as xdmp:function, $param1 as item()*, $error-code as xs:string?)
50-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $error-code as xs:string?)
51-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $error-code as xs:string?)
52-
assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 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()*, $param5 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()*, $param6 as item()*, $error-code as xs:string?)
49+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $error-code as xs:string?)
50+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $error-code as xs:string?)
51+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $error-code as xs:string?)
52+
* assert-throws-error($function as xdmp:function, $param1 as item()*, $param2 as item()*, $param3 as item()*, $param4 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()*, $param5 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()*, $param6 as item()*, $error-code as xs:string?)
5555
assert-throws-error-with-message($function as xdmp:function, $expected-error-code as xs:string, $expected-message as xs:string)
5656
assert-throws-error-with-message($function as xdmp:function, $expected-error-code as xs:string, $expected-message as xs:string, $message as xs:string*)
5757
assert-true($conditions as xs:boolean*)
5858
assert-true($conditions as xs:boolean*, $message as xs:string?)
5959
```
60+
- 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.
Lines changed: 31 additions & 0 deletions
Loading

docs/debugging-tests.md

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

docs/getting-started.md

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

3030
```
3131
dependencies {
32-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
32+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0"
3333
}
3434
```
3535

@@ -48,7 +48,7 @@ buildscript {
4848
mavenCentral()
4949
}
5050
dependencies {
51-
classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
51+
classpath "com.marklogic:marklogic-unit-test-client:1.4.0"
5252
}
5353
}
5454
```

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
---
66

77
marklogic-unit-test includes a simple mechanism for loading test data specific to a test suite. This capability is

0 commit comments

Comments
 (0)