Code Monkey home page Code Monkey logo

Comments (9)

jmakeig avatar jmakeig commented on July 19, 2024 2

2. Manually run setup + test in qconsole

I don’t think we should recommend that. We should recommend a proper test harness and make using that easier than pasting into Query Console.

from marklogic-unit-test.

joecrean avatar joecrean commented on July 19, 2024 1

on point 2.

  1. Use UI to run individual test
    • click open the failing test in the UI in order to view the stack trace which will show which test has failed.
    • be sure to uncheck teardown to view the state of the test data at the time of failure.

on point 4.

  1. Use log statements and error logs to get insight into the run time (tip: if you are testing a REST extension, your test code may be running in a different application server as the application code)
    • would be great to have the debugger working here

from marklogic-unit-test.

damonfeldman avatar damonfeldman commented on July 19, 2024

We identified two main testing patterns in other discussions, which should be documented. These show people both how to debug test failures, and also how to do test-driven development in MarkLogic in the first place.

Fortunately MarkLogic is more functional and componentized than a typical Java project, making it very natural to test components in DHF in particular. Each of the following is a natural, test-able component.

  • DHF plugins
  • declarative mapper mappings
  • TDEs
  • Redaction configuration
  • REST API transforms
  • and the like. For someone using marklogic-unit-test (preferred) the way to actually test and debug is to either
  1. Edit and review in an interactive cycle

    • Edit the tests in some editor
    • Have "gradle mlWatch" running so those edits are pushed immediately
    • Have the testing web page open ( http://localhost:8042/test/default.xqy ) to run one test, or many there
    • Have the log file for your app server open (8042_ErrorLog.txt) so you can see new log statements that you add/tweak
  2. Manually run setup + test in qconsole

    • do an xdmp.invoke(of the setup) - it can't run from qconsole because the module location it is run from matters.
    • run the test in qconsole, and return/log interesting info, or tweak the test in real-time in qconsole

from marklogic-unit-test.

jamesagardner avatar jamesagardner commented on July 19, 2024

I agree with @jmakeig. I don't think reproducing the test context in Query Console is the right long term approach. Query Console is a great place to investigate the database state after a test run, but it's not a well suited run time for tests that may have complex setups and interdependencies.

from marklogic-unit-test.

rhdunn avatar rhdunn commented on July 19, 2024

With my IntelliJ XQuery plugin, I am planning on adding support for running marklogic-unit-test based tests using the test runner framework to handle setup/teardown. These would provide the same workflow and UI/UX as the JUnit based tests.

I'm also planning on adding debugging support for MarkLogic queries, allowing you to debug any issues.

I have support for running (and profiling) queries in MarkLogic in the 1.4.1 version for IntelliJ 2019.1. Using the "Active editor file" option for the query file, I can currently run tests that don't have any setup/teardown requirements.

Errors are displayed in the output with the values from the assert and the stack trace of the function calls. This does not currently link to the files in the editor (like with Java stack traces), but this is something I am looking to implement.

from marklogic-unit-test.

pne avatar pne commented on July 19, 2024

My go-to for figuring out which test failed is to dive into build/test-results/marklogic-unit-test and look at the TEST-*.xml files.

from marklogic-unit-test.

rjrudin avatar rjrudin commented on July 19, 2024

This would be a good addition to our new docs.

from marklogic-unit-test.

rjrudin avatar rjrudin commented on July 19, 2024

DEVEXP-554

from marklogic-unit-test.

rjrudin avatar rjrudin commented on July 19, 2024

Closing, will be part of 1.4.0, tracking via DEVEXP-554.

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.