From ceae8934eb840fd6343610db2a7aad44914bbbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Tue, 18 Sep 2018 15:29:31 +0200 Subject: [PATCH] Writing tests How to tag a test --- CONTRIBUTING.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a18a25c4c..830e7fbb4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,41 @@ Please comment your code ! :-) Imagine an engineer is trying to fix a production When naming variables use strict camel case e.g. use myUrl not myURL. This is so we can automatically convert from camelCase to snake_case for JSON output. +## Writing tests + +When you write a test for an endpoint please tag it with a version and the endpoint. +An example of how to tag tests: +```scala +class FundsAvailableTest extends V310ServerSetup { + + /** + * Test tags + * Example: To run tests with tag "getPermissions": + * mvn test -D tagsToInclude + * + * This is made possible by the scalatest maven plugin + */ + object VersionOfApi extends Tag(ApiVersion.v3_1_0.toString) + object ApiEndpoint extends Tag(nameOf(Implementations3_1_0.checkFundsAvailable)) + + feature("Check available funds v3.1.0 - Unauthorized access") + { + scenario("We will check available without user credentials", ApiEndpoint, VersionOfApi) { + val bankId = randomBankId + val bankAccount = randomPrivateAccount(bankId) + val view = randomViewPermalink(bankId, bankAccount) + When("We make a request v3.1.0") + val request310 = (v3_1_0_Request / "banks" / bankId / "accounts" / bankAccount.bank_id / view / "funds-available").GET + val response310 = makeGetRequest(request310) + Then("We should get a 400") + response310.code should equal(400) + And("error should be " + UserNotLoggedIn) + response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + } + } + +} +``` ## Issues @@ -34,4 +69,4 @@ Please see the NOTICE for each project licence. See the README for instructions on setup and running the tests :-) -Welcome! \ No newline at end of file +Welcome!