Skip to content

Commit c1af128

Browse files
author
gdgate
authored
Merge pull request #1068 from gooddata/liry-patch-3
Describe test best practices in CONTRIBUTING Reviewed-by: Jiri Mikulasek <jiri.mikulasek@gooddata.com> https://github.com/jimirocks
2 parents fa5c9cb + f669311 commit c1af128

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

CONTRIBUTING.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,20 @@ is specific enough.
5959
* `find*()` when searching for multiple objects (collection of objects, never return `null`)
6060
* `list*()` when listing whole or paged collection of objects (return collection or collection wrapped by DTO)
6161
* `remove*()` (i.e. `remove(Project project)`) instead od `delete*()`
62-
* Write **integration tests** for services using _[Jadler](https://github.com/jadler-mocking/jadler/wiki)_.
63-
* If it is possible write **acceptance tests** to be run with the real backend.
62+
* In addition to unit tests, write also **integration tests** and **acceptance tests** if possible. See "What to test where" in "Best practices" below.
6463
* Update [documentation](https://github.com/gooddata/gooddata-java/wiki/Code-Examples) with usage examples.
6564
6665
## Best practices
67-
* **Test class naming**:
68-
* `*Test` unit tests, but avoid service tests using mocked `RestTemplate` - use integration test
69-
* `*IT` integration tests (see [`AbstractGoodDataIT`](src/test/java/com/gooddata/AbstractGoodDataIT.java))
70-
* `*AT` acceptance tests
66+
* **What to test where**:
67+
* `*Test` = unit tests
68+
* focus on verifying bussiness logic, corner cases, various input combinations, etc.
69+
* avoid service tests using mocked `RestTemplate` - use integration tests with mocked API responses instead
70+
* `*IT` = integration tests
71+
* focus on verifying all possible outcomes of API calls
72+
* see common ancestor [`AbstractGoodDataIT`](src/test/java/com/gooddata/AbstractGoodDataIT.java) setting up [Jadler](https://github.com/jadler-mocking/jadler/wiki) for API mocking
73+
* `*AT` = acceptance tests
74+
* focus on verifying the happy path against the real backend (so we're sure mocks in ITs are correct)
75+
* see common ancestor [`AbstractGoodDataAT`](src/test/java/com/gooddata/AbstractGoodDataAT.java) setting up GoodData endpoint based on passed environment variables
7176
* Everything public should be **documented** using _javadoc_.
7277
* When you need some **utility code**, look for handy utilities in used libraries first (e.g. _Spring_ has
7378
its `StreamUtils`, `FileCopyUtils`, ...). When you decide to create new utility class,

0 commit comments

Comments
 (0)