DMSTEX Business Solutions LLC provides Database Design and Generation Services (DDGS). These services include development of Database Schema, PL/SQL API, Test Data, and Maintenance Forms. The following playlist demonstrates some of the details of DDGS.
Advancing automated software engineering for relational technology (Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.)
Saturday, March 28, 2015
Integrating Jenkins and SQL*Developer's Unit Test
The following links are SQL*Developer reports that will produce JUnit formatted output. They are specifically designed and tested to work with Jenkins.
junit_suite_report.xml - Report for a single Test Suite (UPDATED 11-Apr-2015)
junit_test_report.xml - Report for a single Unit Test (UPDATED 11-Apr-2015)
Download the above XML files and load them into SQL*Developer like this:
You can execute tests and reports from the command line.
To Run a Unit Test
sdcli unittest -run -test -name "TEST_NAME" -repo "REPO_CONNECTION" -db "DB_CONNECTION"
Create JUnit Report for a Unit Test
sdcli reports generate -report junit_test_report -db "REPO_CONNECTION" -file "REPORT_FILENAME" -bind "test_name=TEST_NAME"
("junit_test_report" will select that latest run of the Unit Test named in the "test_name" bind variable.)
Run a Test Suite
sdcli unittest -run -suite -name "SUITE_NAME" -repo "REPO_CONNECTION" -db "DB_CONNECTION"
Create JUnit Report for a Test Suite
sdcli reports generate -report junit_suite_report -db "REPO_CONNECTION" -file "REPORT_FILENAME" -bind "suite_name=SUITE_NAME"
("junit_suite_report" will select that latest run of the Test Suite named in the "suite_name" bind variable.)
TEST_NAME - Name of a unit test in SQL*Developer
SUITE_NAME - Name of a test suite in SQL*Developer
REPO_CONNECTION - SQL*Developer connection name for the unit test repository.
DB_CONNECTION - SQL*Developer connection name that will run the unit test.
REPORT_FILENAME - File name for output of the SQL*Developer report.
More information about using the SQL*Developer command line is at
http://www.thatjeffsmith.com/archive/2013/07/sql-developer-4-0-and-the-command-line-interface-cli/.
IMPORTANT
These reports create an HTML file called "REPORT_FILENAME".html. The file must be stripped of the HTML tags and saved as an XML file. The following "sed" command will perform the conversion:
sed -e '1,/^<pre> Remove this line and above$/d' -e '/^Remove this line and below <\/pre>$/,$d' < REPORT_FILENAME.html > REPORT_FILENAME.xml
After the conversion, the XML file should look like an XML file. Jenkins will show errors in the "build console" if something is wrong with the XML file.
To tell Jenkins how to capture the JUnit XML output:
This is an example of JUnit output from SQL*Developer captured by Jenkins from several Test Suites combined into one build.
This is an example of an error captured by Jenkins from SQL*Developer JUnit output.
More information about JUnit XML format for Jenkins is at
http://nelsonwells.net/2012/09/how-jenkins-ci-parses-and-displays-junit-output/
Additional JUnit XML format information is at
http://help.catchsoftware.com/display/ET/JUnit+Format
junit_suite_report.xml - Report for a single Test Suite (UPDATED 11-Apr-2015)
junit_test_report.xml - Report for a single Unit Test (UPDATED 11-Apr-2015)
Download the above XML files and load them into SQL*Developer like this:
- View -> Reports
- Right Click on "User Defined Reports"
- Select "Open Report"
- Select the XML file and Click "Open"
You can execute tests and reports from the command line.
To Run a Unit Test
sdcli unittest -run -test -name "TEST_NAME" -repo "REPO_CONNECTION" -db "DB_CONNECTION"
Create JUnit Report for a Unit Test
sdcli reports generate -report junit_test_report -db "REPO_CONNECTION" -file "REPORT_FILENAME" -bind "test_name=TEST_NAME"
("junit_test_report" will select that latest run of the Unit Test named in the "test_name" bind variable.)
Run a Test Suite
sdcli unittest -run -suite -name "SUITE_NAME" -repo "REPO_CONNECTION" -db "DB_CONNECTION"
Create JUnit Report for a Test Suite
sdcli reports generate -report junit_suite_report -db "REPO_CONNECTION" -file "REPORT_FILENAME" -bind "suite_name=SUITE_NAME"
("junit_suite_report" will select that latest run of the Test Suite named in the "suite_name" bind variable.)
TEST_NAME - Name of a unit test in SQL*Developer
SUITE_NAME - Name of a test suite in SQL*Developer
REPO_CONNECTION - SQL*Developer connection name for the unit test repository.
DB_CONNECTION - SQL*Developer connection name that will run the unit test.
REPORT_FILENAME - File name for output of the SQL*Developer report.
More information about using the SQL*Developer command line is at
http://www.thatjeffsmith.com/archive/2013/07/sql-developer-4-0-and-the-command-line-interface-cli/.
IMPORTANT
These reports create an HTML file called "REPORT_FILENAME".html. The file must be stripped of the HTML tags and saved as an XML file. The following "sed" command will perform the conversion:
sed -e '1,/^<pre> Remove this line and above$/d' -e '/^Remove this line and below <\/pre>$/,$d' < REPORT_FILENAME.html > REPORT_FILENAME.xml
After the conversion, the XML file should look like an XML file. Jenkins will show errors in the "build console" if something is wrong with the XML file.
To tell Jenkins how to capture the JUnit XML output:
- Click on the Build
- Click "Configure"
- Scroll down to "Add Build Step"
- Select "Publish JUnit test result report"
- Enter the location of the XML files in "Test report XMLs"
This is an example of JUnit output from SQL*Developer captured by Jenkins from several Test Suites combined into one build.
This is an example of an error captured by Jenkins from SQL*Developer JUnit output.
More information about JUnit XML format for Jenkins is at
http://nelsonwells.net/2012/09/how-jenkins-ci-parses-and-displays-junit-output/
Additional JUnit XML format information is at
http://help.catchsoftware.com/display/ET/JUnit+Format
Subscribe to:
Posts (Atom)