Skip to content

Commit c150238

Browse files
authored
Merge branch 'master' into dependabot/bundler/docs/activesupport-7.0.7.2
2 parents d3818ab + 76b10a3 commit c150238

Some content is hidden

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

49 files changed

+1284
-652
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: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GEM
1313
execjs
1414
coffee-script-source (1.11.1)
1515
colorator (1.1.0)
16-
commonmarker (0.23.9)
16+
commonmarker (0.23.10)
1717
concurrent-ruby (1.2.2)
1818
dnsruby (1.70.0)
1919
simpleidn (~> 0.2.1)
@@ -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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
layout: default
33
title: Assertion functions
4-
nav_order: 6
5-
permalink: /docs/assertions
4+
nav_order: 7
65
---
76

87
The list below captures the assertion functions available in the marklogic-unit-test `/test/test-helper.xqy` module.
@@ -47,14 +46,15 @@ assert-same-values($expected as item()*, $actual as item()*)
4746
assert-same-values($expected as item()*, $actual as item()*, $message as xs:string*)
4847
assert-throws-error($function as xdmp:function)
4948
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?)
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?)
5655
assert-throws-error-with-message($function as xdmp:function, $expected-error-code as xs:string, $expected-message as xs:string)
5756
assert-throws-error-with-message($function as xdmp:function, $expected-error-code as xs:string, $expected-message as xs:string, $message as xs:string*)
5857
assert-true($conditions as xs:boolean*)
5958
assert-true($conditions as xs:boolean*, $message as xs:string?)
6059
```
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: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
layout: default
33
title: Getting started
44
nav_order: 2
5-
permalink: /docs
65
---
76

87
This guide walks you through adding marklogic-unit-test to an existing project, followed by writing, loading, and
@@ -30,7 +29,7 @@ adding the following configuration to the project's `build.gradle` file:
3029

3130
```
3231
dependencies {
33-
mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
32+
mlBundle "com.marklogic:marklogic-unit-test-modules:1.4.0"
3433
}
3534
```
3635

@@ -40,7 +39,7 @@ in your `build.gradle` file), run the following task to install marklogic-unit-t
4039

4140
./gradlew -i mlLoadModules
4241

43-
If you would like to [run your marklogic-unit-test tests](/docs/running) via Gradle, you'll also need to include the
42+
If you would like to [run your marklogic-unit-test tests](running-tests.md) via Gradle, you'll also need to include the
4443
following at the top of your `build.gradle` file:
4544

4645
```
@@ -49,7 +48,7 @@ buildscript {
4948
mavenCentral()
5049
}
5150
dependencies {
52-
classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
51+
classpath "com.marklogic:marklogic-unit-test-client:1.4.0"
5352
}
5453
}
5554
```
@@ -90,7 +89,7 @@ therefore be stored in the `src/test/ml-modules/root/test/suites/(name of suite)
9089

9190
A test suite can have any name; for this example, we will use "thesaurus" as the name. Test modules can have any name
9291
as well with a few exceptions for setup and teardown modules; those exceptions are covered in the
93-
[guide for writing tests](/docs/writing). We will use "simple-test.sjs" for this example, so we create a
92+
[guide for writing tests](writing-tests.md). We will use "simple-test.sjs" for this example, so we create a
9493
file at `src/test/ml-modules/root/test/suites/thesaurus/simple-test.sjs` with the following initial content:
9594

9695
```
@@ -99,7 +98,7 @@ const lib = require("/example/lib.sjs");
9998
```
10099

101100
The first line above imports the marklogic-unit-test module containing dozens of useful
102-
[assertion functions](/docs/assertions); every test
101+
[assertion functions](assertion-functions.md); every test
103102
module will need this imported. The second line imports the library module that we wish to verify.
104103

105104
Next, add the following text to the file:
@@ -116,7 +115,7 @@ const result = lib.lookupTerm("Car");
116115
The above code will invoke the `lookupTerm` function that we wish to test with a term that we know is in the
117116
application's thesaurus. Each `assertEqual` function call - along with every other assertion function in
118117
marklogic-unit-test - will return a success or failure. The test then returns an array of these successes and failures.
119-
The different approaches for [running tests](/docs/running) know how to collect these results and display how many
118+
The different approaches for [running tests](running-tests.md) know how to collect these results and display how many
120119
tests passed and how many failed.
121120

122121
## Configuring a connection to MarkLogic
@@ -163,7 +162,7 @@ Once you execute either `mlWatch` or `mlLoadModules`, your test will be ready to
163162

164163
## Running a test
165164

166-
marklogic-unit-test provides [several ways to run tests](/docs/running). We will look at the two primary ways to
165+
marklogic-unit-test provides [several ways to run tests](running-tests.md). We will look at the two primary ways to
167166
run the test module we just wrote and loaded into our application's modules database.
168167

169168
First, tests can be run via the ml-gradle `mlUnitTest` task, as long as you have included the
@@ -217,6 +216,6 @@ This guide has covered the following topics:
217216
3. How to load a test.
218217
4. How to run a test.
219218

220-
With the above information and the references on [writing tests](/docs/writing) and
221-
[running tests](/docs/running), you can now start writing tests for the library modules in your application,
219+
With the above information and the references on [writing tests](writing-tests.md) and
220+
[running tests](running-tests.md), you can now start writing tests for the library modules in your application,
222221
ensuring that you can quickly enhance your application without breaking any existing functionality.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ marklogic-unit-test includes the following components:
1919
popular Java testing frameworks.
2020
4. A REST endpoint for integrating with testing frameworks in any language.
2121

22-
Please see the [Getting started guide](/docs) to learn how to include marklogic-unit-test in your
22+
Please see the [Getting started guide](getting-started.md) to learn how to include marklogic-unit-test in your
2323
project and to start writing and running tests.
2424

2525
If you have any questions or run into issues while using marklogic-unit-test, try one of the following:

0 commit comments

Comments
 (0)