-
Notifications
You must be signed in to change notification settings - Fork 31
Integration with Bitbucket Pipelines
Bitbucket Pipelines is a built in CI system for Atlassian Bitbucket.
The following example illustrates how to run XSpec tests in a Pipelines build for a project hosted on Bitbucket.
-
Create the following
bitbucket-pipelines.yml
in the root of your repository:pipelines: default: - step: script: # Install XSpec - echo "Installing XSpec" - git clone -b master https://github.com/xspec/xspec.git /tmp/xspec # Install Saxon - echo "Installing Saxon" - mkdir -p /tmp/saxon - export SAXON_CP=/tmp/saxon/saxon9he.jar - wget -O "${SAXON_CP}" https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.9.1-7/Saxon-HE-9.9.1-7.jar # script - cd test - echo "execute XSpec unit tests" - ./run-xspec-tests.sh
The commands install XSpec in
/tmp/xspec
and the Saxon processor in/tmp/xspec/saxon
and set the path to the Saxon jar. The commands labelledscript
navigate into thetest
directory and run a shell script that executes all the XSpec test suite. Modify the test directory to the location where your XSpec tests are stored. -
Create the shell script
run-xspec-tests.sh
that runs all the XSpec tests in thetest
directory:#! /bin/bash for xspecfile in *.xspec; do if /tmp/xspec/bin/xspec.sh -e "${xspecfile}" &> result.log; then echo "OK: ${xspecfile}" else echo "FAILED: ${xspecfile}" echo "---------- result.log" cat result.log echo "----------" exit 1 fi done
This shell script outputs the name of the successful XSpec test executed. If an XSpec fails, the script stops, provides the name of the failing test and output the error message stored in the log file
result.log
.Note that this
run-xspec-tests.sh
is only for illustration purposes. It is very slow. For more serious purposes, consider using Ant. -
Push to your Bitbucket repository the following files:
-
bitbucket-pipelines.yml
: this must be pushed to the root of the repository you want to test. You can configure different branches to use different scripts. -
run-xspec-tests.sh
: ideally this should be pushed to the same directory where your XSpec tests are located. - your XSpec tests
-
Here is an output of a successful build with XSpec tests on Pipelines:
If you have any questions about XSpec or want to discuss, contribute, and share information with the XSpec community, please go to our issue tracker.
For historical searches, the Google group might also be useful.
- Writing Scenarios
- Nesting Scenarios
- Focusing Your Efforts
- Global Context Item
- Selecting Nodes
- Whitespace-only Text Nodes
- Attribute Value Templates
- Text Value Templates
- Special Names
- Code Coverage
- XML Catalog Support
- Environment Variables
- Testing Dynamic Errors
- Integrating Your Own Test Helpers
- External Transformation
- Getting Started with XSpec and Schematron
- Writing Scenarios for Schematron
- Testing Schematron with Text Nodes
- Testing Schematron with Attributes
- Using Another Implementation of Schematron