mlxprs icon indicating copy to clipboard operation
mlxprs copied to clipboard

Run marklogic-unit-test module

Open rjrudin opened this issue 4 years ago • 2 comments

As I'm writing a marklogic-unit-test module, I want to run a command that runs my module against the /v1/resources/marklogic-unit-test REST extension so that I can get immediate feedback without having to go to the marklogic-unit-test UI in my browser, scroll down to the module, and run it.

  • I'm assuming that I have ml-gradle's mlWatch running, so that as soon as I hit save on my module, it's loaded into my modules database
  • The REST extensions needs params of rs:func=run, rs:suite=suiteName, and rs:tests=filename
  • I think mlxprs can calculate the suite name by working up the directory that the test file is in until it hits "test/suites" - it can assume that that's the root directory of suites. So suite name would be everything after suites - e.g. if the path is "test/suites/my/custom/test.sjs", then suiteName = "my/custom" and tests="test.sjs"

This would be a big productivity boost when writing/testing/fixing marklogic-unit-test tests.

rjrudin avatar Dec 18 '20 17:12 rjrudin

I found that I could do this via the REST Client plugin - e.g. I have this in a buffer:

GET http://localhost:8011/v1/resources/marklogic-unit-test?rs:func=run&rs:suite=data-hub/5/smart-mastering/entity-matching/structured-property&rs:tests=singleValueArrayJsonMatch.sjs Authorization: Digest test-data-hub-developer password

However, that requires a 2nd buffer. Would be better if I could run a test directly from the buffer containing my test module.

rjrudin avatar Dec 18 '20 19:12 rjrudin

Here's what I'm doing for a fast code/test/fix cycle:

  1. I'm using the above REST client plugin, and I have a buffer with the GET statement above. I modify that for whatever test module I'm working on.
  2. I run that buffer once
  3. I then work on my test module, and when I want to run the test, I can just execute the "Rerun last request" REST client plugin action
  4. To make that even easier, I modified the keybinding for "Rerun" so that its "when expression" doesn't care what the language of the current text editor is

Now once I've run the buffer once, I can just hit the keybinding immediately after I change my test module.

Would still be nice to have this baked into the plugin so I don't need to deal with setting up the separate buffer.

rjrudin avatar Jan 08 '21 14:01 rjrudin