Commit 4c1ea5ba by James Cropcho

Merge pull request #51 from todvora/tests-readme-update

Java wrapper description in tests readme
parents c18a25d9 df432588
......@@ -13,6 +13,42 @@ Main indicator of tests result is [exit code](http://tldp.org/LDP/abs/html/exit-
In case of everything went well, return code is `0`. In case of tests fail, exit code is set to nonzero. Exit code is monitored by Travis-CI and informs about tests success or fail.
Tests produce verbose log messages for detecting problems and errors.
## Java wrapper
The bridge between JUnit tests and Variety written in pure JS is [Java wrapper for variety](https://github.com/variety/variety/blob/master/test/src/main/java/com/github/variety/Variety.java).
Currently the wrapper is optimized for tests usage and allows:
- Specify analyzed DB and collection name
- Forward all config parameters to Variety.js
- execute mongo shell with all the config values and path to Variety
- Collect standard output of mongo shell
- Verify results values (assertion)
- Access mongo database through native java driver (initialization, cleanup)
Wrapper can be created with this command:
```
Variety wrapper = new Variety("test", "users");
```
Where the first parameter is analyzed database name and second analyzed collection name. Wrapper is written following
[builder pattern](https://en.wikipedia.org/wiki/Builder_pattern):
```
VarietyAnalysis analysis = new Variety("test", "users")
.withMaxDepth(10)
.withSort("{name:-1}")
.withLimit(5)
.runAnalysis();
```
```VarietyAnalysis``` is the actual analysis result. Main purpose is to easy verify results:
```
verifyResult(String key, double totalOccurrences, double percentContaining, String... types)
```
If the result does not match expectations, AssertionError is thrown (standard JUnit behavior).
## 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`.
......@@ -22,7 +58,7 @@ Tests produce verbose log messages for detecting problems and errors.
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.
## Contribute
You can extend current test cases or create new JUnit test. All tests under `test/src/test/` are automatically included into run.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment