1. dw::test::DWITTestRunner
This runner executes all the DataWeave Integration Test under a given folder
2. dw::test::DWMITTestRunner
3. dw::test::Tests
This module contains all functions required to create a Data Weave test
3.1. Example
Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%dw 2.0
import * from dw::test::Tests
---
"Matcher api" describedBy [
"It should support nested matching" in do {
var payload = {}
---
payload must [
beObject(),
$.foo must [
beNull()
]
]
},
"It should support simple matching" in do {
var payload = {}
---
payload must beObject()
},
"It should support multiple root cases" in do {
var payload = {}
var flowVar = {a: 123}
---
[
payload must beObject(),
flowVar must [
beObject(),
$.a must equalTo(123)
]
]
},
"It should support using custom assertions" in do {
var payload = []
---
payload must sizeOf($) > 2
}
]
3.2. Functions
3.2.1. describedBy
describedBy(suite: String, testsToRun: Array<() → TestResult>): TestResult
Defines a new test suite with the list of test cases.
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
%dw 2.0
import * from dw::test::Tests
---
"Matcher api" describedBy [
"It should support nested matching" in do {
var payload = {}
---
payload must [
beObject(),
$.foo must [
beNull()
]
]
},
]
3.2.2. in
in(testName: String, testCases: () → MatcherResult): TestResult
Defines a new test case inside a test suite with a single assertion.
Example
1
2
3
"It should support nested matching" in do {
"foo" must beString()
}
in(testName: String, callback: Array<() → MatcherResult>): TestResult
Defines a new test case with multiple assertions
Example
1
2
3
4
5
6
7
8
9
10
11
12
"It should support multiple root cases" in do {
var payload = {}
var flowVar = {a: 123}
---
[
payload must beObject(),
flowVar must [
beObject(),
$.a must equalTo(123)
]
]
}
in(testName: String, callback: Array<() → MatcherResult>, skipAll: Boolean): TestResult
3.3. Variables
3.3.1. ERROR_STATUS
3.3.2. FAIL_STATUS
3.3.3. OK_STATUS
3.3.4. SKIP_STATUS
3.4. Types
3.4.1. TEST_STATUS
Data Type that describes the result of a Test Execution
1
"ERROR" | "OK" | "FAIL" | "SKIP"
3.4.2. TestResult
1
{ name: String, time: Number, status: TEST_STATUS, tests?: Array<TestResult>, errorMessage?: String }
4. dw::test::internal::Ansi
4.1. Functions
4.1.1. cyan
cyan(txt: String): String
4.1.2. deletePreviousLine
deletePreviousLine(): String
4.1.3. faint
faint(txt: String): String
4.1.4. green
green(txt: String): String
4.1.5. red
red(txt: String): String
4.1.6. superGreen
superGreen(txt: String): String
4.1.7. superRed
superRed(txt: String): String
4.1.8. superWhite
superWhite(txt: String): String
4.1.9. white
white(txt: String): String
4.1.10. yellow
yellow(txt: String): String
4.2. Variables
4.2.1. SANE
5. dw::test::internal::DWITUtils
5.1. Functions
5.1.1. buildContext
buildContext(dir: String)
5.1.2. createTestCase
createTestCase(scenario: String, testUrl: { content: String, url: String }, context: { _?: Any }, expected: Any, expectedPath: String, mimeType: String): () → TestResult
5.1.3. createTestCases
createTestCases(mappingDir: String, resourceProvider: TestResourceProvider): Array<() → TestResult>
Creates a Single Test Case from the
Parameters
Name | Description |
---|---|
mappingDir |
The mapping directory path |
testUrlProvider |
Factory function that returns the url of the mapping file to be executed |
5.1.4. createTestSuite
createTestSuite(directory: String, resourceProvider: TestResourceProvider): Array<() → TestResult>
Creates all the tests suites from a given directory.
Parameters
Name | Description |
---|---|
directory |
The directory where to search all the test cases |
== Types === TestResourceProvider .Definition [source,DataWeave,linenums]
(mappingDir: String, testCase: String) → { content: String, url: String }
= dw::test::internal::Functions == Functions === interceptor ==== interceptor<T>(before: () -> Any, value: () -> T, after: (T) -> Any): T Helper method to execute something before and after ===== Parameters [%header, cols="1,3"] |=== | Name | Description | before | The method to be executed before | value | The function to be executed | after | The function to be executed after |===
6. dw::test::internal::coverage::Sonar
Generates coverage report based on https://docs.sonarqube.org/latest/analysis/generic-test/
7. dw::test::internal::reporter::Default
8. dw::test::internal::reporter::HtmlAggregator
9. dw::test::internal::reporter::JUnit
9.1. Functions
9.1.1. processTestResult
processTestResult(testResult)
Transforms the test result in a junit compatible test result report
10. dw::test::internal::reporter::Reports
10.1. Functions
10.1.1. totalErrors
totalErrors(testsuite: TestResult)
10.1.2. totalFail
totalFail(testsuite: TestResult)
10.1.3. totalOk
totalOk(testsuite: TestResult)
10.1.4. totalSkip
totalSkip(testsuite: TestResult)
10.1.5. totalTests
totalTests(testsuite: TestResult)
10.1.6. totalWithStatus
totalWithStatus(testsuite: TestResult, statusId: String)
10.2. Types
10.2.1. TestsResult
1
Array<{ name: String, testResult: TestResult }>
11. dw::test::internal::reporter::Sonar
Generates test report based on https://docs.sonarqube.org/latest/analysis/generic-test/
11.1. Functions
11.1.1. processTestResult
processTestResult(testResult: TestsResult): SonarResult
Transforms the test result in a junit compatible test result report
11.2. Types
11.2.1. FileType
1
{| file @(path: String)*: TestCasesType |}
11.2.2. SonarResult
1
{| testExecutions @(version: 1): FileType |}
11.2.3. TestCasesType
1
{| testCase @(name: String, duration: Number)*?: { skipped @(message?: String)?: String | Null, error @(message?: String)?: String | Null, failure @(message?: String)?: String | Null } |}