Writing tests

How to tag a test
This commit is contained in:
Marko Milić 2018-09-18 15:29:31 +02:00 committed by GitHub
parent 96a90c21a4
commit ceae8934eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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!
Welcome!