1. dw::test::DWITTestRunner
1.1. Functions
1.1.1. buildContext
buildContext(String)
1.1.2. createTestCase
createTestCase(String, String, Object, Any): () → TestResult
1.1.3. createTestCases
createTestCases(String): Array<() → TestResult>
1.1.4. createTestSuite
createTestSuite(String): Array<() → TestResult>
2. dw::test::Tests
This module contains all functions required to create a Data Weave test
2.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
}
]
2.2. Functions
2.2.1. describedBy
describedBy(String, 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()
]
]
},
]
2.2.2. in
in(String, () → 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(String, 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)
]
]
}
2.3. Variables
2.3.1. ERROR_STATUS
2.3.2. FAIL_STATUS
2.3.3. OK_STATUS
2.4. Types
2.4.1. TestResult
Data Type that describes the result of a Test Execution
1
{ name: String, time: Number, status: String, tests?: Array<TestResult>, errorMessages?: Array<String> }
3. dw::test::internal::Ansi
3.1. Functions
3.1.1. cyan
cyan(String): String
3.1.2. deletePreviousLine
deletePreviousLine(): String
3.1.3. faint
faint(String): String
3.1.4. green
green(String): String
3.1.5. red
red(String): String
3.1.6. superGreen
superGreen(String): String
3.1.7. superRed
superRed(String): String
3.1.8. superWhite
superWhite(String): String
3.1.9. white
white(String): String
3.1.10. yellow
yellow(String): String
3.2. Variables
3.2.1. SANE
4. dw::test::internal::File
INTERNAL USE ONLY
Simple file module
4.1. Functions
4.1.1. baseNameOf
baseNameOf(String): String
Returns the base name of this file
4.1.2. contentOf
contentOf(String): String
Returns the content of the specified file
4.1.3. extensionOf
extensionOf(String): String | Null
4.1.4. fileTypeOf
fileTypeOf(String): String
Returns the file type. FileType or DirType
4.1.5. ls
ls(String): Array<String>
Return the list of child elements of the specified path.
ls(String, String): Array<String>
Return the list of child elements of the specified path. That matches the specified regex pattern
4.1.6. mimeTypeOf
mimeTypeOf(String): String | Null
Returns the infered mimeType of the specified file if not returns null
4.1.7. nameOf
nameOf(String): String
Returns the name of this file
4.1.8. path
path(String, String): String
Creates a valid path from this two parts
5. dw::test::internal::Functions
5.1. Functions
5.1.1. interceptor
interceptor(() → Any, () → T, (T) → Any): T
6. dw::test::internal::Runner
6.1. Functions
6.1.1. runUrl
runUrl(String, Object): Any
Executes the given mapping url with the specified context
7. dw::test::internal::reporter::Default
8. dw::test::internal::reporter::JUnit
8.1. Functions
8.1.1. processTestResult
processTestResult(testResult)
Transforms the test result in a junit compatible test result report