You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/05/22 19:20:33 UTC
[GitHub] [couchdb] iilyak opened a new pull request #2036: Exunit
iilyak opened a new pull request #2036: Exunit
URL: https://github.com/apache/couchdb/pull/2036
## Overview
Eunit testing framework has a number of deficiencies especially in the cases when mocking is involved. This PR introduces Elixir based ExUnit into our testing stack. This work uses notion of testing adapter which allows us to write test suite once and reuse it to test using different interfaces:
- fabric
- clustered
- backdoor
The PR doesn't include tests themselves. The tests would be included in separate PRs.
Here is one example of how the test might look:
```
defmodule Couch.Test.CRUD do
use ExUnit.Case
alias Couch.Test.Adapter
alias Couch.Test.Utils, as: Utils
alias Couch.Test.Setup
require Record
test_groups = [
"using Clustered API": Adapter.Clustered,
"using Backdoor API": Adapter.Backdoor,
"using Fabric API": Adapter.Fabric,
]
for {describe, adapter} <- test_groups do
describe "Database CRUD #{describe}" do
@describetag setup: %Setup{}
|> Setup.Start.new([:chttpd])
|> Setup.Adapter.new(adapter)
|> Setup.Admin.new(user: "adm", password: "pass")
|> Setup.Login.new(user: "adm", password: "pass")
test "Create", %{setup: setup} do
db_name = Utils.random_name("db")
setup_ctx = setup |> Setup.run()
assert {:ok, resp} = Adapter.create_db(Setup.get(setup_ctx, :adapter), db_name)
assert resp.body["ok"]
end
end
end
end
```
## Testing recommendations
Use `make exunit` to run all tests.
You can also use mix directly as follows:
```
BUILDDIR=`pwd` ERL_LIBS=`pwd`/src MIX_ENV=test mix test --trace
```
## Related Issues or Pull Requests
N/A
## Checklist
- [x] Code is written and works correctly;
- [x] Changes are covered by tests;
- [x] Documentation reflects the changes;
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services