plugin extensions unit testing dita-ot · jason fox (fiware foundation) the views presented in this...
TRANSCRIPT
![Page 1: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/1.jpg)
Unit Testing DITA-OT Plugin Extensions
Jason Fox (FIWARE Foundation)
![Page 2: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/2.jpg)
The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation
1
Disclaimer
![Page 3: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/3.jpg)
New Employer - FIWARE Foundation
2
![Page 4: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/4.jpg)
3
New Employer - FIWARE Foundation
Open Source Friendly - Everything is available on GitHub:
Website: fiware.org
@FIWARE on Twitter
https://github.com/jason-fox/fox.jason.unit-test
![Page 5: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/5.jpg)
Why Unit Testing?
▪ Validate that it does what you want
▪ Check that you haven’t broken something else
▪ Essential safety net for refactoring
Why not unit testing?
▪ Writing tests is difficult
▪ No support tools
▪ Spend more time debugging the tests than the code
4
![Page 6: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/6.jpg)
Why Code Coverage?
▪ Validate your tests are comprehensive
▪ Check that no dead code is left in the code base
▪ Maintain standards
Why Profiling?
▪ Check where bottlenecks occur
5
![Page 7: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/7.jpg)
Demonstration
▪ UNIT TESTING
▪ CODE COVERAGE
▪ ANT PROFILING
6
![Page 8: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/8.jpg)
Unit Test Report and Coverage Report
7
![Page 9: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/9.jpg)
Profiling Report
8
![Page 10: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/10.jpg)
9
Deep Dive - Unit Testing
▪ build-init▪ unit-test.init▪ generate-fixtures▪ unit-test▪ coverage.report▪ unit-test.report
![Page 11: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/11.jpg)
10
Anatomy of a Test Suite Directory
▪ Series of named sub directories:
• One Test = One Dir
▪ Essential file in root
• bootstrap.xml
▪ Other Special Files• coverage.xml• test.properties• disabled.txt
![Page 12: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/12.jpg)
11
Anatomy of a Unit Test
▪ Standard DITA-OT inputs• document.ditamap • *.dita files
▪ Output becomes Test expectation• expected.html• expected.fo• etc
▪ build.xml defines the flowof the test by calling ANT tasks defined in the plugin
![Page 13: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/13.jpg)
12
Simplifying the Unit Tests
▪ cfg - simplifies the Output• attributes.xml - Attributes to ignore in the output• colors.xml - Switches from HEX to readable names• fonts.xml - Switches from your fonts to placeholders (e.g. Monospace)
▪ resource - simplifies the Input - see API Reference• Compare-Output• Contains-Text• Exec-HTML5• Exec-PDF• Exec-Transtype• Get-HMTL-Article• Get-PDF-Article
![Page 14: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/14.jpg)
13
Writing your own Unit Tests
▪ Copy an existing test from the samples in the plugin to get a simple PDF or HTML output
▪ Update the expectation.html/fo Volkswagening test.copy parameter
▪ Run build.xml directly to get verbose output (useful when debugging)
▪ Repeat...
![Page 15: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/15.jpg)
Deep Dive - Code Coverage
▪ Instrument▪ Adds <xsl:message> to each
decision point▪ Unique ID based on number of
preceding nodes▪ Create an empty coverage.xml
file with line numbers and IDs
▪ Coverage Report▪ When unit tests are run, IDs are
piped to output.▪ coverage-report target updates
number of hits▪ XSL transform to HTML and
Cobertura
14
![Page 16: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/16.jpg)
Integration - Travis CI + Coveralls
▪ Use any CI to run tests
▪ coverage.xml is Cobertura-like output
▪ Use standard pom.xml to read file and upload online
▪ Can track coverage over time
▪ Legitimately display and Badges
15
![Page 17: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/17.jpg)
16
Deep Dive - Profiling
Antro▪ Existing ANT listener task▪ Add to classpath and as a listener
Antro UI ▪ GUI can be invoked as a Java Jar▪ Add to classpath and run Java
![Page 18: Plugin Extensions Unit Testing DITA-OT · Jason Fox (FIWARE Foundation) The views presented in this workshop are my own and do not necessarily reflect the views of the FIWARE Foundation](https://reader034.vdocuments.mx/reader034/viewer/2022051909/5ffd03b0130b293f552559eb/html5/thumbnails/18.jpg)
Thank you!
http://fiware.orgFollow @FIWARE on Twitter