tutteli-spek-extensions

A set of Spek extensions

Лицензия

Лицензия

Группа

Группа

ch.tutteli.spek
Идентификатор

Идентификатор

tutteli-spek-extensions
Последняя версия

Последняя версия

1.2.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

tutteli-spek-extensions
A set of Spek extensions
Ссылка на сайт

Ссылка на сайт

https://github.com/robstoll/tutteli-spek-extensions
Система контроля версий

Система контроля версий

https://github.com/robstoll/tutteli-spek-extensions

Скачать tutteli-spek-extensions

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/ch.tutteli.spek/tutteli-spek-extensions/ -->
<dependency>
    <groupId>ch.tutteli.spek</groupId>
    <artifactId>tutteli-spek-extensions</artifactId>
    <version>1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/ch.tutteli.spek/tutteli-spek-extensions/
implementation 'ch.tutteli.spek:tutteli-spek-extensions:1.2.1'
// https://jarcasting.com/artifacts/ch.tutteli.spek/tutteli-spek-extensions/
implementation ("ch.tutteli.spek:tutteli-spek-extensions:1.2.1")
'ch.tutteli.spek:tutteli-spek-extensions:jar:1.2.1'
<dependency org="ch.tutteli.spek" name="tutteli-spek-extensions" rev="1.2.1">
  <artifact name="tutteli-spek-extensions" type="jar" />
</dependency>
@Grapes(
@Grab(group='ch.tutteli.spek', module='tutteli-spek-extensions', version='1.2.1')
)
libraryDependencies += "ch.tutteli.spek" % "tutteli-spek-extensions" % "1.2.1"
[ch.tutteli.spek/tutteli-spek-extensions "1.2.1"]

Зависимости

runtime (3)

Идентификатор библиотеки Тип Версия
org.spekframework.spek2 : spek-dsl-jvm jar 2.0.15
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.21-2
org.jetbrains.kotlin : kotlin-reflect jar 1.4.21-2

Модули Проекта

Данный проект не имеет модулей.

Download Apache license Build Status Ubuntu Build Status Windows SonarCloud Status SonarCloud Coverage

Tutteli spek extension

A set of Spek extensions such as MemoizedTempFolder.

Installation

gradle

repositories {
    mavenCentral()

    // or
    // jcenter()

    // or the following repo    
    // maven {
    //     url  "https://dl.bintray.com/robstoll/tutteli-jars" 
    // }
}

dependencies {
    testImplementation 'ch.tutteli.spek:tutteli-spek-extensions:1.2.1'
}

Features

MemoizedTempFolder

memoizedTempFolder provides -- similar to TemporaryFolder in junit4 -- utility methods to create temp files and folders and takes care of deleting them.

Specify a memoizedTempFolder within a group like scope near to the test you are going to use the tempFolder (default CachingMode is per TEST, so each test gets its own temporary directory)

import memoizedTempFolder
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe

object MySpec: Spek({
    
    describe("...") {
        val tempFolder by memoizedTempFolder()

        it ("...") {
            val file = tempFolder.newFile("test.txt")
        }
    }
})

Pass a CachingMode if required (see Caching modes @ spekframework.org) For instance:

import ch.tutteli.atrium.api.fluent.en_GB.jdk8.*
import ch.tutteli.atrium.verbs.expect
import memoizedTempFolder
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import org.spekframework.spek2.lifecycle.CachingMode

object MySpec: Spek({
    
    describe("...") {
        val tempFolder by memoizedTempFolder(CachingMode.SCOPE)
        
        it ("test1") {
            val file = tempFolder.newFile("test.txt")
            file.delete()
        }
        it("test2"){
            expect(file).exists() // would fail
        }       
    }
})

And you can use the second argument of memoizedTempFolder for additional setup:

import ch.tutteli.atrium.api.fluent.en_GB.*
import ch.tutteli.atrium.verbs.expect
import memoizedTempFolder
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import org.spekframework.spek2.lifecycle.CachingMode

object MySpec: Spek({
    
    describe("...") {
        val tempFolder by memoizedTempFolder(CachingMode.TEST) {
            val f = newDirectory("folderWithinTempFolder")
            newSymbolicLink("link", f)
        }
        
        it ("test1") {
            expect(tempFolder.resolve("folderWithinTempFolder")).exists()
            expect(tempFolder.resolve("link")).exists()   
        }    
    }
})

There are a few other utility methods defined on MemoizedTempFolder: newDirectory, newSymbolicLink, resolves and withinTmpDir.

Tutteli spek extension works best in combination with Niok which enhances Path with methods like createDirectories, setAttribute, writeLines and many more (not only useful in tests but also in production code). With Niok in place, more complicated setup can be defined easily:

import memoizedTempFolder
import ch.tutteli.niok.*
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe
import org.spekframework.spek2.lifecycle.CachingMode

object MySpec: Spek({
    
    describe("...") {
        val tempFolder by memoizedTempFolder(CachingMode.TEST) {
            withinTmpDir {
                val subDir = resolve("dir1/dir2/dir3").createDirectories()
                subDir.resolve("a.txt").writeLines(listOf("a", "b", "c"))
            }
        }
    }
})

And if you like to assert certain properties of a Path, then we recommend using Atrium.

License

tutteli-spek-extensions is licensed under Apache 2.0.

Версии библиотеки

Версия
1.2.1
1.1.0