Giter Club home page Giter Club logo

marklogic-unit-test's Introduction

GitHub release GitHub last commit License

Testing MarkLogic

marklogic-unit-test is a testing framework that allows a project to test MarkLogic code. With one import a project immediately has access to:

  1. A framework for writing and running MarkLogic unit tests, including several built in assertion functions
  2. A UI for viewing and running unit tests entirely within MarkLogic
  3. A REST endpoint to run and report unit tests with other tools

Testing MarkLogic from a Java project is made easy with marklogic-junit5:

  1. Write MarkLogic tests entirely from Java
  2. Easily integrate MarkLogic unit tests into your JUnit 5 project

Start using marklogic-unit-test

MarkLogic unit test can easily be integrated into your project as an ml-bundle. The following steps will configure a project to import and use marklogic-unit-tests.

If you'd like to skip straight to the end, you can check out a working example project. You can use that project's build.gradle file as an example of how to use marklogic-unit-test in your own project.

Add marklogic-unit-test to build.gradle

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "com.marklogic:marklogic-unit-test-client:1.3.0"
    classpath "com.marklogic:ml-gradle:4.5.0"
  }
}

apply plugin: "com.marklogic.ml-gradle"

repositories {
  mavenCentral()
}

dependencies {
  mlBundle "com.marklogic:marklogic-unit-test-modules:1.3.0"
}

Add Test Properties to gradle.properties

# Settings for any ml-gradle project
mlHost=localhost    # Assuming local development
mlAppName=my-app    # Application name, defaults to my-app
mlRestPort=8003     # Application Port, defaults to 8003
mlUsername=         # Username used to manage MarkLogic
mlPassword=         # Password used to manage MarkLogic


# Settings specific to marklogic-unit-test
mlTestRestPort=8004 # Testing port, view and run tests from this port

# ml-gradle supports deploying to multiple environments (https://github.com/marklogic-community/ml-gradle/wiki/Configuring-ml-gradle#environment-based-properties).\
# Add the following line to gradle-{env}.properties files for which you would like to deploy the tests. Typically
# tests are only deployed to environments that execute automated tests, like local development and CI environments.
mlModulePaths=src/main/ml-modules,src/test/ml-modules

Deploy tests using ml-gradle

Now that the environment is configured to load tests and setup a test application servier its time to deploy everything.

./gradlew mlDeploy

To enable quicker feedback between code updates and automated test runs, use the mlWatch task to automatically deploy changes to MarkLogic

./gradlew mlWatch

Access marklogic-unit-test UI

Open a web browser to http://localhost:8004/test/. This is where tests are selected, run, and results are displayed.

If this is a project that's new to marklogic-unit-tests no test suites are displayed because there are no tests.

Creating a test suite

Creating test suites is easy using the mlGenerateUnitTestSuite gradle task. Run the following to setup a sample test suite:

./gradlew mlGenerateUnitTestSuite

More options exist for mlGenerateUnitTestSuite, consult the gradle help

./gradlew help --task mlGenerateUnitTestSuite

Now a new test suite has been generated in src/test/ml-modules/root/test/suites called SampleTestSuite.

If mlWatch is being used, refreshing the web browser at http://localhost:8004/test/ will now show the newly created SampleTestSuite. The suite can be run using the Run Tests button at the top or bottom of the page.

Start using marklogic-junit

Check out the marklogic-junit5 sub-project to get started using marklogic-junit5.

marklogic-unit-test's People

Contributors

jamesagardner avatar rjrudin avatar dmcassel avatar hansenmc avatar cskeefer avatar ryanjdew avatar paxtonhare avatar daveegrant avatar billfarber avatar venuiyengar avatar peetkes avatar prestonmcgowan avatar dependabot[bot] avatar jonesyface avatar

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.