Skip to content

Commit

Permalink
docu
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone committed Dec 1, 2022
1 parent de694fe commit 3b369ef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/05-internals/development/building-and-running.md
Expand Up @@ -114,7 +114,7 @@ The docker plugin also allows for a number of other useful features, like inspec
To run all test targets, use the following in the command line:

```
$ make test
$ make test-all
```

To run a single test from the command line, for example `SearchV1R2RSpec`,
Expand Down
54 changes: 35 additions & 19 deletions docs/05-internals/development/testing.md
Expand Up @@ -5,30 +5,46 @@

# Testing

## How to Write Unit Tests
## How to Write and Run Unit Tests

1) Inside a test, at the beginning, add the following (change the paths
to the test data as needed):
A test is not a [unit test](https://www.martinfowler.com/bliki/UnitTest.html) if:

```scala
val rdfDataObjects = List (
RdfDataObject(path = "test_data/responders.v1.ValuesResponderV1Spec/incunabula-data.ttl", name = "http://www.knora.org/data/incunabula")
)
```
The data will be automatically loaded before any tests are executed. These tests should be stored inside
the `src/test` folder hierarchy.
* It talks to the database
* It communicates across the network
* It touches the file system
* It can’t run at the same time as any of your other unit tests
* You have to do special things to your environment (such as editing config files) to run it

2) Call the test from terminal:
Unit tests live in the `src/test` folder of our sbt projects.

Run all unit tests from terminal:

```shell
sbt test
```
$ make test-unit
$ make test-e2e
```

## How to Write Integration Tests
## How to Write and Run Integration Tests

[Mostly you should consider writing unit tests](https://www.youtube.com/watch?v=VDfX44fZoMc). These can be executed fast and help developers more in their daily work.

You might need to create an integration test because:

The only difference between Integration and Unit tests is the location
where they are stored and the way how they are called:
* The test needs to talk to a database
* It requires network
* it is slow and cannot run in parallel with other tests
* You have to do special things to the environment in order to run it

In this case create it in the `src/it` source set of our projects.

.NOTE
_Currently only the `webapi` project supports it tests_

Run all integration tests from the terminal.

```shell
make integration-test
```

1) Store tests inside the `src/it` folder hierarchy.
2) Call the tests from the terminal: `make test-it`
.NOTE
_The integration tests currently depend on a locally published Sipi container. That is why we need to start
the `make` command and not `sbt it`._

0 comments on commit 3b369ef

Please sign in to comment.