mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 11:06:49 +00:00
Writing tests
How to tag a test
This commit is contained in:
parent
96a90c21a4
commit
ceae8934eb
@ -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!
|
||||
|
||||
Loading…
Reference in New Issue
Block a user