Skip to content

Commit 702145e

Browse files
committed
Merge branch 'develop'
2 parents 54b5063 + 883636c commit 702145e

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.iml
44
.DS_Store
55
build
6+
out

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=0.9.1
2+
version=0.10.0
33

44
# These properties are used for the test application that ml-gradle deploys so we can test out ml-unit-test
55
mlAppName=marklogic-unit-test-testapp

src/main/java/com/marklogic/test/unit/TestManager.java

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
*/
1515
public class TestManager extends ResourceManager {
1616

17+
public final static String FORMAT_JUNIT = "junit";
18+
19+
/**
20+
* The "none" format means that the XML will be returned from the ml-unit-test endpoint without any additional
21+
* formatting applied to it.
22+
*/
23+
public final static String FORMAT_NONE = "";
24+
1725
private ServiceResponseUnmarshaller unitTestXmlParser;
1826

1927
public TestManager(DatabaseClient client) {
@@ -59,9 +67,21 @@ public List<String> listSuites() {
5967
* @return
6068
*/
6169
public TestSuiteResult run(TestModule testModule) {
62-
RequestParameters params = new RequestParameters();
63-
params.add("func", "run");
64-
params.add("suite", testModule.getSuite());
70+
return run(testModule, true, true);
71+
}
72+
73+
/**
74+
*
75+
* Run a single test module. This is intended to be used in a parameterized JUnit test, where each test
76+
* module is intended to correspond to a separate JUnit test.
77+
*
78+
* @param testModule
79+
* @param runTeardown
80+
* @param runSuiteTeardown
81+
* @return
82+
*/
83+
public TestSuiteResult run(TestModule testModule, boolean runTeardown, boolean runSuiteTeardown) {
84+
RequestParameters params = buildRequestParameters(testModule.getSuite(), FORMAT_NONE, runTeardown, runSuiteTeardown);
6585

6686
String test = testModule.getTest();
6787
if (test != null) {
@@ -76,10 +96,20 @@ public TestSuiteResult run(TestModule testModule) {
7696
* @return a JUnitTestSuite for every suite found in the modules database
7797
*/
7898
public List<JUnitTestSuite> runAllSuites() {
99+
return runAllSuites(true, true);
100+
}
101+
102+
/**
103+
*
104+
* @param runTeardown
105+
* @param runSuiteTeardown
106+
* @return a JUnitTestSuite for every suite found in the modules database
107+
*/
108+
public List<JUnitTestSuite> runAllSuites(boolean runTeardown, boolean runSuiteTeardown) {
79109
List<String> suiteNames = listSuites();
80110
List<JUnitTestSuite> suites = new ArrayList<>();
81111
for (String suiteName : suiteNames) {
82-
suites.add(runSuite(suiteName));
112+
suites.add(runSuite(suiteName, runTeardown, runSuiteTeardown));
83113
}
84114
return suites;
85115
}
@@ -93,14 +123,19 @@ public JUnitTestSuite runSuite(String suite) {
93123
}
94124

95125
public JUnitTestSuite runSuite(String suite, boolean runTeardown, boolean runSuiteTeardown) {
126+
RequestParameters params = buildRequestParameters(suite, FORMAT_JUNIT, runTeardown, runSuiteTeardown);
127+
String xml = getServices().post(params, (AbstractWriteHandle) null, new StringHandle()).get();
128+
return unitTestXmlParser.parseJUnitTestSuiteResult(xml);
129+
}
130+
131+
protected RequestParameters buildRequestParameters(String suite, String format, boolean runTeardown, boolean runSuiteTeardown) {
96132
RequestParameters params = new RequestParameters();
97133
params.add("func", "run");
98134
params.add("suite", suite);
99-
params.add("format", "junit");
135+
params.add("format", format);
100136
params.add("runsuiteteardown", String.valueOf(runSuiteTeardown));
101137
params.add("runteardown", String.valueOf(runTeardown));
102-
String xml = getServices().post(params, (AbstractWriteHandle) null, new StringHandle()).get();
103-
return unitTestXmlParser.parseJUnitTestSuiteResult(xml);
138+
return params;
104139
}
105140

106141
public void setUnitTestXmlParser(ServiceResponseUnmarshaller unitTestXmlParser) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xdmp:log("Suite teardown")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xdmp:log("Test teardown")

0 commit comments

Comments
 (0)