A specification framework for Kotlin

Overview

GitHub Workflow Status Maven Central Sonatype Nexus (Snapshots)

Spek Logo

A Test Framework for Kotlin

Visit the web site for more documentation and information.

Current State of the Project

  • Spek 2.x is main development branch, see 2.0.0 Milestone.
  • Spek 1.x is in support mode, only bug fixes and documentation updates will be merged into 1.x branch.

Copyright (c) 2018, Spek Core Team and Contributors

Licensed under Modified BSD

Comments
  • NoClassDefFoundError when using mocks and running spek from IntelliJ on a Windows machine

    NoClassDefFoundError when using mocks and running spek from IntelliJ on a Windows machine

    Hello,

    Please consider the following test (using MockK):

    class MockkSpec : Spek({
      val mock = mockk<Greeter>()
    
      beforeEachTest {
        every { mock.greet(any()) } answers { "Hello ${args[0]}" }
      }
    
      afterEachTest {
        clearMocks(mock)
      }
    
      describe("greet(\"mock\")") {
        val result by memoized { mock.greet("mock") }
    
        it("should return \"Hello mock\"") {
          assertEquals("Hello mock", result)
        }
      }
    })
    

    It runs fine from gradle (graldew test). But running the test from IntelliJ fails with:

    Exception in thread "main" java.lang.NoClassDefFoundError: io/mockk/proxy/jvm/dispatcher/JvmMockKDispatcher
    	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
    	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622)
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580)
    	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    	at io.mockk.proxy.jvm.transformation.SubclassInstrumentation$AdviceBuilder.build(SubclassInstrumentation.kt:28)
    	at io.mockk.proxy.jvm.transformation.SubclassInstrumentation.<init>(SubclassInstrumentation.kt:33)
    	at io.mockk.proxy.jvm.JvmMockKAgentFactory$init$Initializer.init(JvmMockKAgentFactory.kt:92)
    	at io.mockk.proxy.jvm.JvmMockKAgentFactory.init(JvmMockKAgentFactory.kt:123)
    	at io.mockk.impl.JvmMockKGateway.<init>(JvmMockKGateway.kt:46)
    	at io.mockk.impl.JvmMockKGateway.<clinit>(JvmMockKGateway.kt:169)
    	at playground.MockkSpec$1.invoke(MockkSpec.kt:37)
    	at playground.MockkSpec$1.invoke(MockkSpec.kt:11)
    	at org.spekframework.spek2.runtime.AbstractRuntime.resolveSpec(SpekRuntime.kt:27)
    	at org.spekframework.spek2.runtime.SpekRuntime.discover(SpekJvmRuntime.kt:35)
    	at org.spekframework.ide.Spek2ConsoleLauncher.run(console.kt:21)
    	at org.spekframework.ide.ConsoleKt$main$1.invoke(console.kt:34)
    	at org.spekframework.ide.ConsoleKt$main$1.invoke(console.kt)
    	at shadow.com.xenomachina.argparser.SystemExitExceptionKt.mainBody(SystemExitException.kt:74)
    	at shadow.com.xenomachina.argparser.SystemExitExceptionKt.mainBody$default(SystemExitException.kt:72)
    	at org.spekframework.ide.ConsoleKt.main(console.kt:32)
    Caused by: java.lang.ClassNotFoundException: io.mockk.proxy.jvm.dispatcher.JvmMockKDispatcher
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    	... 34 more
    

    Please also note that it doesn't concern only Mockk. Using Mockito also fail:

    Exception in thread "main" java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
    	at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:74)
    	at com.sun.proxy.$Proxy2.isTypeMockable(Unknown Source)
    	at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
    	at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
    	at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:238)
    	at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:226)
    	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:68)
    	at org.mockito.Mockito.mock(Mockito.java:1896)
    	at org.mockito.Mockito.mock(Mockito.java:1805)
    	at playground.MockitoSpec$1.invoke(MockitoSpec.kt:11)
    	at playground.MockitoSpec$1.invoke(MockitoSpec.kt:10)
    	at org.spekframework.spek2.runtime.AbstractRuntime.resolveSpec(SpekRuntime.kt:27)
    	at org.spekframework.spek2.runtime.SpekRuntime.discover(SpekJvmRuntime.kt:35)
    	at org.spekframework.ide.Spek2ConsoleLauncher.run(console.kt:21)
    	at org.spekframework.ide.ConsoleKt$main$1.invoke(console.kt:34)
    	at org.spekframework.ide.ConsoleKt$main$1.invoke(console.kt)
    	at shadow.com.xenomachina.argparser.SystemExitExceptionKt.mainBody(SystemExitException.kt:74)
    	at shadow.com.xenomachina.argparser.SystemExitExceptionKt.mainBody$default(SystemExitException.kt:72)
    	at org.spekframework.ide.ConsoleKt.main(console.kt:32)
    Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@21129f1f
    	at org.mockito.internal.configuration.plugins.PluginInitializer.loadImpl(PluginInitializer.java:54)
    	at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:57)
    	at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:44)
    	at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:21)
    	at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:18)
    	at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
    	... 16 more
    Caused by: org.mockito.exceptions.base.MockitoInitializationException: 
    Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)
    

    And finally also note that running the Junit5 equivalents works just fine, even when triggered from IntellIJ.

    is: bug 
    opened by jcornaz 37
  • Fails to find tests with Kotlin version 1.1.4

    Fails to find tests with Kotlin version 1.1.4

    Spek is unable to find any of the tests when run with the newly released Kotlin 1.1.4 but works with 1.1.3-2. Spek version is 1.1.2, Gradle version is 4.1

    When run with 1.1.3-2

    Test run finished after 5478 ms
    [        31 containers found      ]
    [         0 containers skipped    ]
    [        31 containers started    ]
    [         0 containers aborted    ]
    [        31 containers successful ]
    [         0 containers failed     ]
    [        20 tests found           ]
    [         0 tests skipped         ]
    [        20 tests started         ]
    [         0 tests aborted         ]
    [        20 tests successful      ]
    [         0 tests failed          ]
    

    When run with 1.1.4

    Test run finished after 5049 ms
    [         1 containers found      ]
    [         0 containers skipped    ]
    [         1 containers started    ]
    [         0 containers aborted    ]
    [         1 containers successful ]
    [         0 containers failed     ]
    [         0 tests found           ]
    [         0 tests skipped         ]
    [         0 tests started         ]
    [         0 tests aborted         ]
    [         0 tests successful      ]
    [         0 tests failed          ]
    
    opened by lispyclouds 34
  • Robolectric extension to support android unit tests

    Robolectric extension to support android unit tests

    Fixes - https://github.com/spekframework/spek/issues/65 I still need to add documentation, unit tests, and code styling but sending an early PR for feedback. I have never written kotlin so it can be rusty.

    There are multiple limitations since unlike JUnit, Spek doesn't create a new instance of the unit test. Method level configs and multiple SDK support for tests are not available. I will add the limitations in the doc.

    Also, there are lifecycle callbacks which can't be used since it expects a java.lang.reflect.Method. Need to think about it carefully and remove those (they won't be invoked).

    opened by bangarharshit 29
  • Running (spring) integration speks?

    Running (spring) integration speks?

    Is there an equivalent for the following JUnit?

    @RunWith(SpringJUnit4ClassRunner::class)
    @ContextConfiguration(classes = arrayOf(Application::class), loader = SpringApplicationContextLoader::class)
    @WebIntegrationTest
    
    opened by jasperblues 26
  • Spek setup ignores Spock and JUnit tests

    Spek setup ignores Spock and JUnit tests

    I have both Spock and JUnit tests in folders parallel to the Spek tests, but these are just ignored by both the IDE and Gradle CLI. Is there something else I need to configure for the JUnitPlatform?

    Relevant parts of build.gradle:

    buildscript { ext.kotlin_version = '1.1.3-2'

    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
    }
    
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4'
    }
    

    }

    apply plugin: 'kotlin' apply plugin: 'org.junit.platform.gradle.plugin'

    junitPlatform { filters { engines { include 'spek' } } }

    repositories { mavenLocal() jcenter() mavenCentral() }

    version ='0.0.0.1'

    dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    testCompile ('org.jetbrains.spek:spek-api:1.1.2') {
        exclude group: 'org.jetbrains.kotlin'
    }
    testRuntime ('org.jetbrains.spek:spek-junit-platform-engine:1.1.2') {
        exclude group: 'org.junit.platform'
        exclude group: 'org.jetbrains.kotlin'
    }
    

    testRuntime "org.junit.platform:junit-platform-launcher:1.0.0-M4" }

    opened by davidsowerby 25
  • Add support for

    Add support for "groups" inside ActionBody

    I was surprised to learn that I can put context blocks inside describe and other group blocks but not inside on (action) blocks. I would like to be able to group it blocks within an on. e.g.:

    describe("/persons") {
        val personsWebTarget = rootWebTarget.path("persons")
        on("GET") {
            val response by lazy { personsWebTarget.request().get() }
            it("should have response status 200 (OK) status code") {
                assertThat(response.status).isEqualTo(200)
            }
            context("Response Headers") {
                it("should have Transfer-Encoding: chunk") {
                    assertThat(response.getHeaderString("Transfer-Encoding")).isEqualTo("chunked")
                }
                it("should have Date that satisfies RFC 7231 and is recent") {
                    assertThat(Duration.between(response.date.toInstant(), Instant.now()))
                            .isLessThan(Duration.ofSeconds(3))
                }
                it("should have Content-Type: application/json;charset=UTF-8") {
                    assertThat(response.mediaType)
                            .isEqualTo(MediaType.APPLICATION_JSON_TYPE.withCharset("UTF-8"))
                }
            }
            ...
        }
        ...
    }
    
    opened by mfulton26 24
  • Android Studio 3.0

    Android Studio 3.0

    Hiya,

    I'm a bit confused how the setup of Spek for Android projects should be. Previously in Android Studio 2.3.3 everything seemed to be working just fine with the Spek plugin installed.

    Following the documentation I retried from scratch in a clean new project since I can't share my particular project. The problem seems to exist there as well.

    Upon running I get:

    WARNING: TestEngine with ID 'spek' failed to discover tests org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: vrt.be.rijckaert.tim.spekproblem.CalculatorSpec

    I also tried to add a compileDebugUnitTestSources Gradle task before running the unit tests.

    You can find the full example here How can I get Spek to run with Android Studio 3.0.0 ? To my understanding something goes wrong with the new bundled JUnit 5 runner?

    Thanks in advance

    Tim

    opened by timrijckaert 22
  • Spek tests not runnable from Maven

    Spek tests not runnable from Maven

    I've been trying to get Spek to run from Maven for over a day now. I've followed all guides and examples I could find on the internet, but with no luck. I can run them in my IDE (IntelliJ), manually, but cannot get them to automatically run in bulk.

    The documentation on how to run Spek from Maven on the official website, is very incomplete in my opinion (http://spekframework.org/docs/latest/#_maven). The pom has to be removed to allow compilation even.

    Can anyone lend me a hand on this please? I've attached my entire pom.xml file (but have removed some private values). My tests/specifications have classnames of the form "...Spec.kt". pom.xml.zip

    Thanks in advance!

    • Ruud
    opened by RuudPaulissen 22
  • Remove Action in favour of Group and Test combination

    Remove Action in favour of Group and Test combination

    Issue

    At this point there are two ways to do the same thing — using action and group.

    group("service") {
        
        beforeEachTest { 
            service.start()
        }
        
        test("it calls backend") {
            verify(backend).call()
        }
    }
    
    action("service") {
    
        service.start()
        
        test("it calls backend") {
            verify(backend).call()
        }
    }
    

    The difference is obvious — it is possible to omit beforeEachTest when using action. At the same time action cannot be nested. Before 2.0 this could lead to nasty bugs related to putting nested groups into action which were essentially ignored. Fortunately enough @DslMarker magic solved this for us. It leaves a couple of open issues though.

    Alien Concept

    Judging from experience — not a lot of people recognize what the difference is and when to use group and when to use action. And it is actually understandable. People coming from JUnit have to live with two completely new concepts (action and group) because the previous experience introduced them only to test. People coming from other languages do not get it as well — as far as I know RSpec from Ruby, Mamba from Python and Quick from Swift do not have action concept at all. The concept of action becomes kind of alien to them.

    BTW — at current projects I work on we just ban action altogether to avoid bugs (2.0 is not released yet). And even 2.0 would not solve things like #388.

    Scale

    At the same time action does not scale well. I’ve encountered a lot of situations when product changes extend the behaviour. I. e. click shows content becomes click shows content and another click shows screen. Fortunately we have nesting but action in such case needs to be migrated to group anyway since action does not support nesting.

    Syntax

    Since we are leaning to have two styles in 2.0 it becomes not quite obvious what is action and what is group.

    • Specification — describe (group) + context (group) + it (test).
    • Gherkin — given (group) + when (group) + then (test) + and (test).

    There is basically no room for action at this point.

    Tech

    Internally having both group and action brings some complexity. I would not say it makes things drastically worse but it is something to have to live with.


    CC @raniejade @hhariri @artem-zinnatullin

    opened by arturdryomov 21
  • Add support for tests with coroutines

    Add support for tests with coroutines

    Would it be possible to add cdescribe, ccontext, cBeforeEachTest and cit, etc.. (for example), that would have a runBlocking (or the new TestCoroutine system...) inside... that would avoid extra nesting (like mockk.io did...).

    is: feature 
    opened by dave08 20
  • Android Project Test do not run if there is an IT block

    Android Project Test do not run if there is an IT block

    @RunWith(JUnitPlatform::class)
    class ExampleUnitTest : Spek({
        given("a test") {
            val test = Test()
            on("thisIsTrue is false"){
                test.thisIsTrue = false
                it("should be false"){
                    assertEquals(false, test.thisIsTrue)
                }
            }
        }
    })
    

    Resluts in "0 of 1 test" "Process finished with exit code 0"

    If I don't have an IT block the test will run fine.

    @RunWith(JUnitPlatform::class)
    class ExampleUnitTest : Spek({
        given("a test") {
            val test = Test()
            on("thisIsTrue is false"){
                test.thisIsTrue = false
                assertEquals(false, test.thisIsTrue)
            }
        }
    })
    
    opened by LewisRhine 20
  • klib publishing fails due to missing checksum

    klib publishing fails due to missing checksum

    Requires one-of SHA-1: /org/spekframework/spek2/spek-runtime-native-macos/2.0.19/spek-runtime-native-macos-2.0.19.klib.sha1, MD5: /org/spekframework/spek2/spek-runtime-native-macos/2.0.19/spek-runtime-native-macos-2.0.19.klib.md5, SHA-256: /org/spekframework/spek2/spek-runtime-native-macos/2.0.19/spek-runtime-native-macos-2.0.19.klib.sha256, SHA-512: /org/spekframework/spek2/spek-runtime-native-macos/2.0.19/spek-runtime-native-macos-2.0.19.klib.sha512
    
    status: triage 
    opened by raniejade 0
  • Incompatible with 2022.2.1

    Incompatible with 2022.2.1

    Hi @raniejade I get the message Incompatible: requires IDE build 213.* or earlier on the Android Studio Electric Eel | 2022.2.1 Canary 5 #AI-221.4165.146.2211.8713749, built on June 17, 2022.

    Yet, I have to stay on Android Studio Electric Eel | 2022.1.1 Canary 3 #AI-213.7172.25.2211.8624637, built on May 21, 2022.

    When will you have a chance to support the new version? Thanks!

    status: triage 
    opened by DmitriyZaitsev 9
  • Multiplatform status?

    Multiplatform status?

    I am working on a Kotlin multiplatform project (iOS and Android only for now) and would love to give Spek a try, however all threads that refer to it seem to indicate that only JVM is supported.

    Since those are all pretty old, could we get clarity on what the roadmap is (+ maybe timeline?) and what's currently supported?

    status: triage 
    opened by remvst 1
  • Gherkin rule dsl missing

    Gherkin rule dsl missing

    Hi guys,

    First thank you for this framwork.

    I think we miss some kind of Group between Feature and Scenario on Gherkin implementation. In fact there is actually such definition on Gherkin specification: https://cucumber.io/docs/gherkin/reference/#rule

    I would like to add it in the framework if it don't bother you?

    I think it is just a matter of extension, BUT when I try to do it in my codebase, green arrow button on Android Studio has been replaced by "Do Nothing" text.

    Can you help me on this issue?

    Edit: Seems to be a duplicate of https://github.com/spekframework/spek/issues/873

    @Synonym(SynonymType.GROUP, prefix = "Rule: ")
    @Descriptions(Description(DescriptionLocation.VALUE_PARAMETER, 0))
    fun FeatureBody.Rule(description: String, body: RuleBody.() -> Unit) =
        delegate.group("Rule: $description",
            defaultCachingMode = CachingMode.EACH_GROUP,
            preserveExecutionOrder = true,
            failFast = true) {
            body(RuleBody(this))
        }
    
    @SpekDsl
    class RuleBody(val delegate: GroupBody) : LifecycleAware by delegate {
        var defaultTimeout: Long
            get() = delegate.defaultTimeout
            set(value) {
                delegate.defaultTimeout = value
            }
    
        @Synonym(SynonymType.GROUP, prefix = "Scenario: ")
        @Descriptions(Description(DescriptionLocation.VALUE_PARAMETER, 0))
        fun Scenario(description: String, body: ScenarioBody.() -> Unit) {
            delegate.group("Scenario: $description",
                defaultCachingMode = CachingMode.SCOPE,
                preserveExecutionOrder = true,
                failFast = true) {
                body(ScenarioBody(this))
            }
        }
    
        @Synonym(SynonymType.GROUP, prefix = "Rule: ")
        @Descriptions(Description(DescriptionLocation.VALUE_PARAMETER, 0))
        fun Rule(description: String, body: RuleBody.() -> Unit) =
            delegate.group("Rule: $description",
                defaultCachingMode = CachingMode.EACH_GROUP,
                preserveExecutionOrder = true,
                failFast = true) {
                body(RuleBody(this))
            }
    
        fun beforeEachScenario(fixture: Fixture) = delegate.beforeEachGroup(fixture)
        fun afterEachScenario(fixture: Fixture) = delegate.afterEachGroup(fixture)
        fun beforeFeature(fixture: Fixture) = delegate.beforeGroup(fixture)
        fun afterFeature(fixture: Fixture) = delegate.afterGroup(fixture)
    
        @Deprecated("Use beforeEachScenario instead", ReplaceWith("beforeEachScenario(fixture)"))
        override fun beforeEachGroup(fixture: Fixture) = beforeEachScenario(fixture)
    
        @Deprecated("Use afterEachScenario instead", ReplaceWith("afterEachScenario(fixture)"))
        override fun afterEachGroup(fixture: Fixture) = afterEachScenario(fixture)
    
        @Deprecated("Use beforeFeature instead", ReplaceWith("beforeFeature(fixture)"))
        override fun beforeGroup(fixture: Fixture) = beforeFeature(fixture)
    
        @Deprecated("Use afterFeature instead", ReplaceWith("afterFeature(fixture)"))
        override fun afterGroup(fixture: Fixture) = afterFeature(fixture)
    }
    
    
    status: triage 
    opened by sebastien-delaherche 0
  • Incompatible with IntelliJ IDEA 2022.1

    Incompatible with IntelliJ IDEA 2022.1

    Launching IntelliJ IDEA 2021.3 with the latest Spek version results in the following error when launching the IDE:

    Plugin 'Spek Framework' (version '2.0.17-IJ2021.2') is not compatible with the current version of the IDE, because it requires build 212.* or older but the current build is IU-213.5744.223

    As a result, none of the plugin's features are available. The plugin should be updated to support the latest IDE version.

    Additionally, because this is not the first time that the plugin is incompatible with the latest version (cf. #829, #834, #889, #939, #954, #980), I think it might be worthwhile to stop restricting the until version supported by the plugin, so that the plugin is considered compatible with all future versions by default. I admit I'm not intimately familiar with Spek's architecture, but it's not clear to me why a different release is created for each IDE version.

    status: triage 
    opened by FWDekker 25
Releases(2.0.19)
  • 2.0.18(Mar 29, 2022)

    What's Changed

    • Update Kotlin, gradle-intellij-plugin and add support for IJ 2021.3 by @raniejade in https://github.com/spekframework/spek/pull/991

    Full Changelog: https://github.com/spekframework/spek/compare/2.0.17...2.0.18

    Source code(tar.gz)
    Source code(zip)
  • 2.0.16(Apr 13, 2021)

  • 2.0.15(Dec 14, 2020)

  • 2.0.14(Nov 14, 2020)

    In 2.0.13 discovery and execution started using coroutines, which means they are not confined to a single thread anymore. This can be problematic as most test frameworks like mokk (and possibly mockito) rely on test execution to be confined in a single thread (#923). Another side effect is that the test execution order wasn't deterministic anymore as at any given point a coroutine can be suspended and control is given elsewhere. This release fixes both that issue, Spek is still using coroutines but the runtime ensures that a given test class will always be confined to a single thread.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.13(Sep 12, 2020)

    This release adds several system properties to control how Spek does discovery and execution.

    1. spek2.discovery.parallel.enabled - controls whether discovery is done in parallel or not, by default it is disabled. The presence of this property regardless of value will enable parallel discovery.

    2. spek2.execution.parallel.enabled - controls whether execution is done in parallel or not, by default it is disabled. The presence of this property regardless of value will enable parallel execution.

    3. spek2.execution.test.timeout - SPEK2_TIMEOUT is now deprecated (will be removed in 2.1.0) and will be replaced by this property. Controls how long a test can run before timing out, by default it is disabled - i.e tests won't timeout.

    A note for parallel execution

    Parallelism is at a class level not individual test scopes. Spek uses coroutines under the hood to execute tests in parallel, essentially spek2.execution.parallel.enabled just controls which CoroutineDispatcher is used. For parallel executions Dispatchers.Default is used, otherwise the one provided by runBlocking is used.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.12(Jul 5, 2020)

    Patch release that adds support for IJ 2020.2 EAP and AS 4.0. The following AS and IJ versions are no longer supported:

    • Android Studio 3.3
    • Android Studio 3.4
    • IntelliJ IDEA 2018.2
    • IntelliJ IDEA 2018.3
    • IntelliJ IDEA 2019.1
    • IntelliJ IDEA 2019.2
    Source code(tar.gz)
    Source code(zip)
  • 2.0.11(Jun 4, 2020)

    Small patch release to disable timeouts by default. Having timeouts is a good idea but unfortunately the feature is not that customizable (i.e there's no way to disable timeouts via the IDE). Once its issues are fix I will consider in enabling it by default again.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.10(Mar 7, 2020)

    This releases add supports for Android Studio 3.6 and IntelliJ IDEA 2020.1

    New features

    • Support for Android Studio 3.6
    • Support for IntelliJ IDEA 2020.1 EAP
    • New IDE inspection for spek classes without a no-arg constructor not marked abstract or any of the following annotations: @Ignore, @InstanceFactory. (#806)
    • The IJ test runner now explicitly exits even if there are non-daemon threads around after test execution. (#848)

    Deprecations and removals

    • CachingMode.GROUP has now been deleted, this was deprecated a couple of release ago. (#798)
    Source code(tar.gz)
    Source code(zip)
  • 2.0.9(Dec 9, 2019)

    A minor release to support the release of IntelliJ IDEA 2019.3 (see #809).

    New features

    (#799) New fixture aliases added to the gherkin style

    The following aliases are now available in the gherkin style:

    • Scenario.beforeScenario -> Scenario.beforeGroup
    • Scenario.afterScenario -> Scenario.afterGroup
    • Scenario.beforeEachStep -> Scenario.beforeEachTest
    • Scenario.afterEachStep -> Scenario.afterEachTest
    • Feature.beforeEachScenario -> Feature.beforeEachGroup
    • Feature.afterEachScenario -> Feature.afterEachGroup
    • Feature.beforeFeature -> Feature.beforeGroup
    • Feature.afterFeature -> Feature.afterGroup

    The aliased fixtures will be deprecated in the context of the gherkin style.

    Deprecations

    (#798) Usage of CachingMode.GROUP is now considered an error

    This mode was replaced by CachingMode.EACH_GROUP on version 2.0.3.

    Others

    • (#820) Bump JUnit Platform dependency to 1.5.2
    • (#808) Internal refactoring to use coroutines more.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.8(Oct 6, 2019)

    Artifacts are now synced to maven central

    See #764 for more details.

    Timeouts

    Test timeouts were added in 2.0.3 but it was hard to configure and there was no way to disable it - causing issues when using a debugger. This release includes several improvements to this feature.

    Setting timeouts globally

    (#769) On the JVM the global timeout can be configured via the system property SPEK_TIMEOUT

    Disable timeouts

    (#792) A value of 0 will disable the timeout.

    Fixtures

    New fixtures

    (#670) beforeEachGroup and afterEachGroup fixtures are now available. They are invoked for every group including the group where they are declared (similar to how CachingMode.EACH_GROUP works).

    Deprecation

    (#787) The fixture aliases before, after, beforeEach and afterEach in the specification style are now deprecated.

    Scope value (aka memoized) access are now stricter

    (#789) Scope values will now throw an exception when accessed in the wrong context. A good example is accessing a scope value with CachingMode.TEST in a beforeGroup fixture. See ticket for the motivation and more details.

    LifecycleListener now reports test failures.

    See #761 for the motivation and more details.

    Other fixes/changes

    • (#737) Validating a return value examples show use of lateinit on primitives which throws a compiler error
    • (#750) Allow running tests on source root
    • (#763) Run all specs in a package of a common module
    • (#794) Improve how run configurations are named
    Source code(tar.gz)
    Source code(zip)
  • 2.0.7(Sep 10, 2019)

  • 2.0.6(Jul 28, 2019)

    • (#706) Provide Kotlin JS and Kotlin Native artifacts for spek-dsl (running tests on those platform is not supported yet).
    • (#712) Support AS 3.5 Beta
    • (#720) Upgrade to the latest classgraph version.
    • (#738) Support IntelliJ IDEA 2019.2
    • (#714) Fail fast gherkin style.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.5(May 29, 2019)

    • Allow timeouts to be customized (specification + gherkin style)
    • Support AS 3.4.1
    • Make IJ plugin more lenient about unsupported kotlin platforms (see #704)
    Source code(tar.gz)
    Source code(zip)
  • 2.0.4(May 8, 2019)

    The following critical bug fixes are included in this release:

    • (#684) failed assertions yields a passing test.
    • (#682) Kotlin reflection errors.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(Apr 30, 2019)

    New features

    Test timeouts (#647)

    The test scope builders (it, Given, When, Then and And) now have an optional parameter timeout that controls how long this test should run until a timeout is issued. The default timeout is 10 seconds.

    Known issues

    • IDE plugins now require Kotlin plugin 1.3.30+ installed.
    • Run tests in a package provided by the Spek plugin does not work most of the time (still investigating), in the meantime use Run tests in package functionality provided by IJ or AS.
    • 2.0.3 IDE plugins are not backward compatible, please use the same version for the project dependency.

    Deprecations

    • (#668) Deprecated CachingMode.GROUP in favor of CachingMode.EACH_GROUP.

    Other changes

    • (#649) Another round of discovery bug fixes.
    • (#666) Fix run tests in a package.
    • (#674) Upgrade to Kotlin 1.3.30.
    • (#676) Update build ranges to support latest Android Studio 3.4.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Apr 8, 2019)

  • 2.0.1(Mar 2, 2019)

    First bugfix release in the 2.x line.

    Fixing #606 required making some incompatible changes between 2.0.1 runtime and 2.0.0 IJ plugin, please hold off from upgrading to 2.0.1 until the IJ plugin is available (it usually takes a few hours as JB needs to manually approve them first). If you have existing run configurations created using the 2.0.0 IJ plugin, you need to recreate them. Apologies for any inconvenience this has caused!

    Fixes

    • (#563) NoClassDefFoundError when using mocks and running spek from IntelliJ on a Windows machine
    • (#574) Couldn't run test clicking in the greens arrows alongside of the class
    • (#606) Error "No test were found" when running tests from a package that contains other packages
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Feb 3, 2019)

    What's new?

    • A new runtime that does not depend JUnit 5, which means we can eventually add support for other kotlin platforms (JS, Native). JUnit 5 is still used a runner for Kotlin JVM.
    • Writing tests for common modules is possible but IDE experience is not desirable (see https://github.com/spekframework/spek/tree/2.x/samples/multiplatform).
    • Support for the new MPP model introduced in Kotlin 1.3.
    • DSL is now split into two distinct styles: specification and gherkin.
    • Better IDE support (see https://spekframework.org/running/#ide)
    • New package name (org.spekframework.spek2)
    • Revamped docs (see https://spekframework.org/)

    Breaking changes

    See https://spekframework.org/breaking-changes/

    Migration guide

    See https://spekframework.org/migration/

    The list of issues and features included can be found in the following milestones:

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-rc.1(Sep 30, 2018)

    First release candidate for Spek 2.x.

    • Add preserveExecutionOrder flag, to guarantee the order of execution (#497)
    • Deploy separate plugins for the different AS versions (#481)
    • Add/fix docs and samples.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.2(Sep 1, 2018)

  • v1.2.1(Sep 1, 2018)

  • v1.2.0(Jul 27, 2018)

    Version is not sync into central, please add https://dl.bintray.com/spekframework/spek/ as an additional maven repository.

    • Support for Java 10
    • Upgrade to Kotlin 1.2.51
    • Upgrade to JUnit Platform 1.1.1
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-alpha.1(Jul 7, 2018)

    First alpha release for 2.x.

    Build is published on bintray, add https://dl.bintray.com/spekframework/spek-dev to your maven repository list.

    repositories {
        maven {
            url  "https://dl.bintray.com/spekframework/spek-dev"
        }
    }
    

    Breaking Changes

    • group id and package prefix is now org.spekframework.spek2.
    • Split DSL into two distinct styles: specification and gherkin.
    • Actions scopes are no more.
    • subject and data-driven extensions are dropped.

    New Features

    • Initial support for Kotlin Multiplatform, you can write common and jvm tests (see https://github.com/spekframework/spek-multiplatform-example).
    • New IDE plugin (still pending JB approval)
    • Child scopes can now access memoized values declared on the parent, this is will allow for reusable scopes (via extensions).
    fun Suite.doFoo() {
      val foo by memoized()
    
       ...
    }
    
    object MyBar: Spek({
      val foo by memoized { createFoo() }
    
      doFoo()
    })
    
    Source code(tar.gz)
    Source code(zip)
  • v1.1.5(Sep 21, 2017)

  • v1.1.4(Aug 23, 2017)

  • v1.1.3(Aug 20, 2017)

  • v1.1.2(May 24, 2017)

  • v1.1.1(May 3, 2017)

Owner
Spek Framework
A Specification framework written in Kotlin
Spek Framework
A programmer-oriented testing framework for Java.

JUnit 4 JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. For more infor

JUnit 8.4k Jan 9, 2023
Android Unit Testing Framework

Robolectric is the industry-standard unit testing framework for Android. With Robolectric, your tests run in a simulated Android environment inside a

Robolectric 5.6k Jan 3, 2023
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.

Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability. Often testability corresponds to go

PowerMock 3.9k Jan 5, 2023
A powerful test framework for Android

Cafe A powerful test framework for Android named Case Automated Framework for Everyone. Home Page http://baiduqa.github.com/Cafe/ How to make Cafe dow

Baidu 367 Nov 22, 2022
A programmer-oriented testing framework for Java.

JUnit 4 JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. For more infor

JUnit 8.4k Dec 28, 2022
A powerful test framework for Android

Cafe A powerful test framework for Android named Case Automated Framework for Everyone. Home Page http://baiduqa.github.com/Cafe/ How to make Cafe dow

Baidu 367 Nov 22, 2022
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.

Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability. Often testability corresponds to go

PowerMock 3.9k Jan 2, 2023
Selenium WebDriver and Appium based Web, Mobile (Android, iOS) and Windows desktop Automation Framework with BDD & Non-BDD implementation support

Selenium WebDriver and Appium based Web, Mobile (Android, iOS) and Windows desktop Automation Framework with BDD & Non-BDD implementation support

null 10 Dec 5, 2022
Raccoon is a lightweight response mocking framework that can be easily integrated into the Android UI tests.

Raccoon Medium Articles Checkout these article to get more insights about this library: How to integrate this in your Android Test Why Raccoon? There

Joseph James 52 Aug 15, 2022
Most popular Mocking framework for unit tests written in Java

Most popular mocking framework for Java Current version is 3.x Still on Mockito 1.x? See what's new in Mockito 2! Mockito 3 does not introduce any bre

mockito 13.6k Jan 4, 2023
Morsa: Jetpack Compose UI Testing Framework

Morsa: Jetpack Compose UI Testing Framework Test library to ease UI testing with Jetpack Compose Purpose This library aims to add some useful wrappers

HyperDevs 10 Dec 3, 2022
A micro mocking framework for KMP

Micro-Mock A micro Kotlin/Multiplatform Kotlin Symbol Processor that generates Mocks & Fakes. Limitations: Mocking only applies to interfaces Faking o

null 101 Jan 3, 2023
Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project.

Kotlin API for React Test Renderer Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project. How

Xavier Cho 7 Jun 8, 2022
A multiplatform assertion library for Kotlin

Atrium is an open-source multiplatform assertion library for Kotlin with support for JVM, JS and Android. It is designed to support multiple APIs, dif

Robert Stoll 439 Dec 29, 2022
Portable validations for Kotlin

Portable validations for Kotlin ✅ Type-safe DSL ?? Multi-platform support (JVM, JS) ?? Zero dependencies Installation For multiplatform projects: kotl

null 509 Dec 18, 2022
mocking library for Kotlin

Kotlin Academy articles Check the series of articles "Mocking is not rocket science" at Kt. Academy describing MockK from the very basics of mocking u

MockK 4.8k Jan 3, 2023
Strikt is an assertion library for Kotlin intended for use with a test runner such as JUnit, Minutest, Spek, or KotlinTest.

Strikt is an assertion library for Kotlin intended for use with a test runner such as JUnit, Minutest, Spek, or KotlinTest.

Rob Fletcher 447 Dec 26, 2022
Fixtures for Kotlin providing generated values for unit testing

A tool to generate well-defined, but essentially random, input following the idea of constrained non-determinism.

Appmattus Limited 191 Dec 21, 2022
A Kotlin Android library for heuristics evasion that prevents your code from being tested.

EvadeMe An Android library for heuristics evasion that prevents your code from being tested. User Instructions Add the maven repository to your projec

Chris Basinger 29 Dec 26, 2022