If the result does not match expectations, AssertionError is thrown (standard JUnit behavior).
If the result does not match expectations, AssertionError is thrown (standard JUnit behavior). There are two possibilities,
how to obtain results. Variety can store results in collection in MongoDB, or output results as a valid JSON to standard
output. This two ways have own representations in wrapper:
- runDatabaseAnalysis
- runJsonAnalysis
Both of them preset important options for Variety (quiet, persistResults, outputFormat) to comply with validator.
## Tests lifecycle
- Initialization, prepare data. Every test has method annotated with `@Before`.
- Variety analysis, run variety.js against prepared data and verify results. See `Variety.java`, method `runAnalysis()` and methods annotated with `@Test`.
- Variety analysis, run variety.js against prepared data and verify results. See `Variety.java`, method `runDatabaseAnalysis()` and methods annotated with `@Test`.
- Resources cleanup, see method annotated with `@After`.
## Used databases and collections
Tests use two databases, `test` and `varietyResults`. In DB `test`, there will be created collection `users`.
Collection is later analyzed by variety and results stored in DB `varietyResults`, collection `usersKeys`.
Cleanup method should remove both test and analysis data.
Cleanup method should remove both test and analysis data. In case of JSON validator, there is no results db/collection created.
## Contribute
You can extend current test cases or create new JUnit test. All tests under `test/src/test/` are automatically included into run.
Assert.assertEquals("Variety results have not correct count of entries",8,analysis.getResultsCollection().count());// 8 results, including '_id' and 'name'
Assert.assertEquals("Variety results have not correct count of entries",5,analysis.getResultsCollection().count());// 5 results, including '_id' and 'name'
Assert.assertEquals("Variety results have not correct count of entries",5,analysis.getResultsCount());// 5 results, including '_id' and 'name'