Skip to content

Commit 34ad231

Browse files
authored
Merge pull request #750 from yadavan88/testing-commands
Added description and readme about different categories of tests
2 parents 399214a + 0047f59 commit 34ad231

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# scala-tutorials
22

3+
In this repository, we have classified the tests in 4 categories.
4+
5+
| Category | Description |
6+
| -- |---------------------------------------------------------------------------------------------------------------------------------------------------------------|
7+
| Unit Tests | Smallest unit of testing, that are not dependent on external tools or services |
8+
| Integration Tests | IntegrationTests means those tests that use some automatic setup within our environment like in-memory Mongo, h2 database etc which don't need explicit setup |
9+
| Live Tests | Tests that depends on some external services (like httpbin.org, or some internet-based links) |
10+
| Manual Tests | The tests where we need to set up an environment explicitly(for e.g. docker), without which the tests can't be run |
11+
12+
13+
Here is a table describing about the different categories of tests and how they can be executed in this project.
14+
15+
| Category | Sbt command | Test class location | Test class name format |
16+
|-------------------------|-------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
17+
| Unit Tests | `sbt ci` | `src/test/scala` or `src/test/scala-2` | No particular format restriction, but as a standard, filename ends with `Test` |
18+
| Integration Test (Only) | `sbt integrationTests` | `src/it/scala` or `src/it/scala-2` | No format restriction, but as a standard, filename ends with `IntegrationTest` |
19+
| Unit & Integration Test | `sbt ciFull` | `src/it/scala` or `src/it/scala-2` | No format restriction, but as a standard, filename ends with `IntegrationTest`. These exclude manual and live tests |
20+
| Live Test | `sbt liveTests` | `src/it/scala` or `src/it/scala-2` | Test class name must end with `LiveTest` |
21+
| Manual Test | `sbt manualTests` | `src/it/scala` or `src/it/scala-2` | Test class name must end with `ManualTest` |
22+
323
# Code fomatting
424

525
Before creating a PR, make sure the code is correctly formatted running `sbt scalafmt`.

build.sbt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,22 @@ addCommandAlias(
491491
";clean;compile;test:compile;it:compile;scalafmtCheckAll;test"
492492
)
493493

494+
addCommandAlias(
495+
"integrationTests",
496+
""";set ThisBuild/IntegrationTest/testOptions += Tests.Filter(t => !t.endsWith("ManualTest") && !t.endsWith("LiveTest") ); it:test""".stripMargin
497+
)
498+
494499
addCommandAlias(
495500
"ciFull",
496501
""";ci; set ThisBuild/IntegrationTest/testOptions += Tests.Filter(t => !t.endsWith("ManualTest") && !t.endsWith("LiveTest") ); it:test""".stripMargin
497502
)
503+
498504
addCommandAlias(
499505
"manualTests",
500506
""";ci; set ThisBuild/IntegrationTest/testOptions += Tests.Filter(t => t.endsWith("ManualTest")); it:test""".stripMargin
501507
)
508+
509+
addCommandAlias(
510+
"liveTests",
511+
""";ci; set ThisBuild/IntegrationTest/testOptions += Tests.Filter(t => t.endsWith("LiveTest")); it:test""".stripMargin
512+
)

0 commit comments

Comments
 (0)