This is the project for homework from Rita.
- Compare two XML files and test if them similar.
- Use TestNG, Java 8, log4j
I use log4j2 with configuration file log4j2.xml. All logs goes to console and to the log file (logs/output.log by default).
-
Set up properties
task_one_gold_data=src/data/gold_data/A.xml task_one_output_data=src/data/output_data/B.xml task_one_ignore_nodes=paratext;cite.query
where
Property Description task_one_gold_data Control XML file we will compare against task_one_output_data XML file we will test and compare with Control task_one_ignore_nodes XML node names (array of values separated with ';' or ',') to ignore during comparing. May be empty. Another way to set up these properties is to pass it through CLI.
example:
mvn clean test -Ptask1 \ -Dtask_one_gold_data=src/data/gold_data/A.xml \ -Dtask_one_output_data=src/data/output_data/B.xml \ -Dtask_one_ignore_nodes=paratext\;cite.query
Note that I use this priority to get properties (from more important to less important)
- Environment variables
- System Properties
- Properties from test.properties file
If both test.properties and System Properties have the same value, I use System property :)
-
Run tests using Maven
mvn clean test -Ptask1
- Compare two big XML files and test if them similar.
- Files are comparing by pairs with names A-B, A1-B1, A2-B2
- All data files are in the Files.zip archive that we put to the project directory before test execution
- Files from the archive extracts to appropriate directories (gold_data and output_data) automatically
- Ignore tag <cite.query> while comparing. We only need to ignore the node definitions and save the text. The text should be compared as part of node.
- Add file error.log with
All logs goes to console and to the log file (logs/output.log by default).
Comparison differences goes to file logs/error.log
-
Set up properties
task_two_ignore_nodes_definitions=cite.query task_two_zip_data_file=../Files.zip task_two_gold_data_folder=src/data/gold_data task_two_output_data_folder=src/data/output_data
where
Property Description task_two_ignore_nodes_definitions Xml node names to ignore their definitions task_two_zip_data_file Data files ZIP archive task_two_gold_data_folder Folder with control XML files we will compare against task_two_output_data_folder Folder with XML files we will test and compare with Control files Another way to set up these properties is to pass it through CLI as mentioned above in the task1.
-
Put the ZIP archive with control and test files to the root project directory or wherever you want but set task_two_zip_data_file with absolute file path then.
-
Run tests using Maven
mvn clean test -Ptask2