Skip to content

Commit

Permalink
Merge pull request #2 from testit-tms/fix/TMS-29851-docs
Browse files Browse the repository at this point in the history
fix: TMS-29851: update docs [0.1.1]
  • Loading branch information
taipoxinous authored Nov 22, 2024
2 parents 4d8d0a9 + 38dc781 commit bffe48b
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 148 deletions.
219 changes: 217 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,220 @@ Supported test frameworks :
1. [Kotest](https://kotest.io/docs/framework/framework.html)


# 🚀 Warning
- If value from @WorkItemIds annotation not found in TMS then test result will NOT be uploaded.
#### 🚀 Warning
- If value from @WorkItemIds annotation not found in TMS then test result will NOT be uploaded.


## Metadata of autotest

Use metadata to specify information about autotest.


Description of metadata:

* `externalId` - unique internal autotest ID (used in Test IT)
* `links` - links listed in the autotest card
* `workItemIds` - a value that links autotests with manual tests. Receives the array of manual tests' IDs
* `attachments` - autotests attachments list
* `name` - internal autotest name (used in Test IT)
* `title` - autotest name specified in the autotest card. If not specified, the name from the displayName method is used
* `message` - autotest message
* `itemStatus` - autotest itemStatus
* `description` - autotest description specified in the autotest card
* `labels` - tags listed in the autotest card


All autotest metadata described with `TestItContext` class using `testCase.setContext()`:

```kotlin
data class TestItContext (
var uuid: String? = null,
var externalId: String? = null,
var links: MutableList<LinkItem>? = null,
var workItemIds: MutableList<String>? = null,
var attachments: MutableList<String>? = null,
var name: String? = null,
var title: String? = null,
var message: String? = null,
var itemStatus: ItemStatus? = null,
var description: String? = null,
var parameters: MutableMap<String, String>? = null,
var labels: MutableList<Label>? = null,
)
```

Example:

```kotlin
testCase.setContext(TestItContext(
name = "isPythagTriple($a, $b, $c)",
labels = mutableListOf(Label("123"))
))
```



## Examples

### Default example:

```kotlin
package org.example.tests

import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.shouldBe
import ru.testit.listener.TestItReporter
import ru.testit.models.LinkItem
import ru.testit.models.LinkType
import ru.testit.models.TestItContext
import ru.testit.utils.*

// isStepContainer true, 2 tests, before + after(failed): failed
class BeforePassedAfterPassed : DescribeSpec({
// enable steps by true parameter
extensions(TestItReporter(true))
beforeTest {
}
// executes even if beforeTest is failed
afterTest {
it.testItAfterTest {
"afterTest" shouldBe "failed"
}
}
it("test1 passed, afterTest failed -> failed") {
3 + 4 shouldBe 7
}
it("test2 failed, afterTest failed -> failed") {
"TestBody" shouldBe "Failed"
}
})

```


### Steps container example

```kotlin
package org.example.tests

import io.kotest.core.spec.style.DescribeSpec
import io.kotest.matchers.shouldBe
import ru.testit.listener.TestItReporter
import ru.testit.models.LinkItem
import ru.testit.models.LinkType
import ru.testit.models.TestItContext
import ru.testit.utils.*

// isStepContainer true, 1 test, 2 steps before + after(failed): ok + failed
class BeforeAfterSteps : DescribeSpec({
extensions(TestItReporter(true))

beforeTest {
it.setSetupName("beforeTest")
}

// executes even if beforeTest is failed
afterTest {
it.a.setTeardownName("afterTest")
it.testItAfterTest {
}
}

describe("describe step container test") {
testCase.asStepContainer()
testCase.setContext(
TestItContext(
links = mutableListOf(
LinkItem(url = "https://google.com", title = "",
description = "", type = LinkType.BLOCKED_BY)
)
)
)
it("an inner step1 - failed") {
"Step1" shouldBe "Failed"
}
it("an inner step2 - pass") {
3 + 4 shouldBe 7
}
}
})
```

### Step container with FunSpec style

```kotlin
package org.example.tests

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import ru.testit.listener.TestItReporter
import ru.testit.models.Label
import ru.testit.models.TestItContext
import ru.testit.utils.asStepContainer
import ru.testit.utils.setContext

class StepContextTest : FunSpec({
extensions(TestItReporter(true, ))


context("fun step spec test") {
testCase.asStepContainer()
testCase.setContext(TestItContext(
labels = mutableListOf(Label("some label1"))
))

test("shouldFail_") {
true shouldBe false
}

test("shouldPass") {
true shouldBe true
}
}

})

```

### Parametrized test example

```kotlin
package org.example.tests

import io.kotest.core.spec.style.FunSpec
import io.kotest.datatest.withData
import io.kotest.matchers.shouldBe
import ru.testit.listener.TestItReporter
import ru.testit.models.Label
import ru.testit.models.TestItContext
import ru.testit.utils.setContext
import ru.testit.utils.testItAfterTest


data class PythagTriple(val a: Int, val b: Int, val c: Int)
fun isPythagTriple(a: Int, b: Int, c: Int): Boolean = a * a + b * b == c * c


class NestingTest : FunSpec({
val testit = TestItReporter(true)
extensions(testit)

context("Pythag triples tests") {
withData(
PythagTriple(3, 4, 5),
PythagTriple(6, 8, 10),
PythagTriple(8, 15, 17),
PythagTriple(7, 24, 25),
PythagTriple(7, 7, 7),

) { (a, b, c) ->
testCase.setContext(TestItContext(
name = "isPythagTriple($a, $b, $c)",
labels = mutableListOf(Label("123"))
))
isPythagTriple(a, b, c) shouldBe true
}
}

})
```
4 changes: 2 additions & 2 deletions testit-adapter-kotest/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Add this dependency to your project POM:
<dependency>
<groupId>ru.testit</groupId>
<artifactId>testit-adapter-kotest</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -23,7 +23,7 @@ Add this dependency to your project POM:
Add this dependency to your project build file:

```groovy
implementation "ru.testit:testit-adapter-kotest:0.1.0"
implementation "ru.testit:testit-adapter-kotest:0.1.1"
```


Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-kotest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "ru.testit"
version = "0.1.0"
version = "0.1.1"

java {
withJavadocJar()
Expand Down

This file was deleted.

Loading

0 comments on commit bffe48b

Please sign in to comment.