Closed tternquist closed 6 years ago
Can we prioritize this being fixed as there is currently no alternative for unit testing with SJS.
@tternquist @rjkennedy98 I just submitted a PR to fix this. Would either of you be able to check out that version and confirm that it works the way you're looking for?
@dmcassel Yes, I can do some verification. Thanks.
Its working for me. Thanks @dmcassel
Actually, looking more closely. There are a few weird things:
<testsuite errors="0" failures="0" hostname="localhost" name="edl-ml-cash-pos" tests="2" time="0.049995" timestamp="">
<testcase classname="suiteSetup.sjs" name="suiteSetup.sjs" time="0.0079992"/>
<testcase classname="get.sjs" name="get.sjs" time="0.0319968"/>
<testcase classname="suiteSetup.sjs" name="suiteSetup.sjs" time="0.0059994"/>
<testcase classname="suiteTeardown.sjs" name="suiteTeardown.sjs" time="0.0019998"/>
</testsuite>
Here is our get.sjs:
var cashPos = require("/marklogic.rest.resource/edl-ml-cash-pos/assets/resource.sjs")
var test = require('/test/test-helper.xqy');
function testHappyPath() {
var params = {
"accountId": "0116928",
"asOfDate": "2017-09-10",
"positionSK": "74779212",
}
var context = {}
var response = cashPos.GET(context, params);
xdmp.log(response);
return test.assertExists(response);
}
[ testHappyPath()];
@rjkennedy98 I just pushed a commit that should fix that. Please retest.
@tternquist @rjkennedy98 ping. I think the PR fixes this bug, but it would be helpful to have a quick independent test. Either of you have a little time to do so?
@dmcassel It seems to be working now. 2 things to note: 1) the Unit Test Wiki has incorrect documentation on how to do the tests Unit Test Wiki
2) The secret sauce is doing flatten out all the assertions.
[].concat(testOne(), testTwo())
fixed in dev
CC @dmcassel
The issue
Short description of the problem: When using SJS unit tests the outputs do not appear to be correctly reported. Instead of a count, the output for tests run, passed and failed are each "-"
What are the steps to reproduce the problem? Can reproduce with these contents as a test file under any test suite:
When run i see the following:
Tech Specs
Which Operating System are you using? MacOS Sierra
Which version of MarkLogic are you using? 9.0-2
Which version of Roxy are you using (see version.txt)? v1.7.7