Code Monkey home page Code Monkey logo

Comments (7)

dmcassel avatar dmcassel commented on August 18, 2024 1

I'm curious what your proposed solution would look like.

from marklogic-unit-test.

grtjn avatar grtjn commented on August 18, 2024

PR #139.. make sure to read the comment.. ;)

from marklogic-unit-test.

grtjn avatar grtjn commented on August 18, 2024

@dmcassel, WDYT?

from marklogic-unit-test.

dmcassel avatar dmcassel commented on August 18, 2024

@dmcassel, WDYT?

Sorry, been swamped. Trying to get to this.

from marklogic-unit-test.

rjrudin avatar rjrudin commented on August 18, 2024

There's definitely good value here, as the user need of "Load some data (in a separate transaction) before this test runs" is common - there's a good bit of plumbing in the DHF marklogic-unit-test tests to do exactly that. And that's different from the user need of "Load these documents before any tests run so that they're available for all tests" - mlDeploy can satisfy that need via e.g. src/test/ml-data. But that's a separate need.

I'm wondering though if there's an easy button to provide for users so that they can avoid multi-statement XQuery modules? Those are a bit more complex and run counter to the current pattern of "Look in the setup/teardown modules to find setup/teardown stuff".

For example, here's what a setup.xqy module looks like in DHF that both clears out some data and loads some test-specific data:

xquery version "1.0-ml";
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
hub-test:reset-hub();

xquery version "1.0-ml";
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
import module namespace test = "http://marklogic.com/test" at "/test/test-helper.xqy";
hub-test:load-artifacts($test:__CALLER_FILE__),
hub-test:load-jobs($test:__CALLER_FILE__)

I think multi-statement setup modules are fine because we don't have to parse out what's the setup logic and what's the actual test logic.

What seems even better though is if MLUT just loaded the data (if detected for a particular test module) automatically via separate transactions. Then the user doesn't need any new code - they just add their data files and collections/permissions and they're off and running.

from marklogic-unit-test.

grtjn avatar grtjn commented on August 18, 2024

How about the following: setup/teardown are invoked between each test case, right? What if you would receive the test case (file) name as a parameter, so that you can decide how/what to setup/teardown. I could easily get rid of the multi statements in that case. Just haven't dug in, to figure out what is needed for that.

As a bonus, you could use sjs as well in that case, since multistatements are not possible in sjs, without resorting to evals/invokes.

The helper functions I created in PR #139 could then be invoked to help with loading/removing test case specific test data. They could probably use a little bit of polishing, but we have been using them for over a year now, and are very happy with it so far.

from marklogic-unit-test.

rjrudin avatar rjrudin commented on August 18, 2024

I'm closing this for now until a request like this pops up again. With the docs we have for loading data, I think this is already pretty easy for a user to do - just toss some basic code into the setup or suite setup, where it's also easy to configure permissions and collections. We'd need to invent a way otherwise for permissions/collections to be configured for the test-data documents.

Also, my preference is not to delete data after a test ends - that allows for easier debugging if the test fails, as well as manual inspection of how data was modified. I prefer for data to be deleted before a test begins instead.

from marklogic-unit-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.