diff --git a/src/main/kotlin/io/kotest/plugin/intellij/Test.kt b/src/main/kotlin/io/kotest/plugin/intellij/Test.kt index 3b60772f..3262a940 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/Test.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/Test.kt @@ -56,7 +56,8 @@ data class Test( val specClassName: KtClassOrObject, // the containing class name, which all tests must have val testType: TestType, val xdisabled: Boolean, // if true then this test was defined using one of the x methods - val psi: PsiElement // the canonical element that identifies this test + val psi: PsiElement, // the canonical element that identifies this test + val isDataTest: Boolean = false ) { // true if this test is not xdisabled and not disabled by a bang and not nested inside another disabled test diff --git a/src/main/kotlin/io/kotest/plugin/intellij/psi/utils.kt b/src/main/kotlin/io/kotest/plugin/intellij/psi/utils.kt index 895b8544..50248436 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/psi/utils.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/psi/utils.kt @@ -127,3 +127,8 @@ fun KtValueArgumentList.isSingleStringTemplateArg(): Boolean = && children[0] is KtValueArgument && children[0].children.size == 1 && children[0].children[0] is KtStringTemplateExpression + +fun LeafPsiElement.isDataTestMethodCall(dataTestMethodNames:Set): KtCallExpression? { + val lambdaCall = ifCallExpressionLambdaOpenBrace() + return lambdaCall.takeIf {lambdaCall?.functionName() in dataTestMethodNames} +} diff --git a/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/GradleTaskNamesBuilder.kt b/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/GradleTaskNamesBuilder.kt index bb519cd7..84c02279 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/GradleTaskNamesBuilder.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/GradleTaskNamesBuilder.kt @@ -39,7 +39,11 @@ data class GradleTaskNamesBuilder( private fun includeArg(): String? { return when (test) { null -> "$PROPERTY_INCLUDE='${spec.fqName?.asString()}'" - else -> "$PROPERTY_INCLUDE='${test.descriptorPath()}'" + else -> + when(test.isDataTest){ + false -> "$PROPERTY_INCLUDE='${test.descriptorPath()}'" + true -> "$PROPERTY_INCLUDE='${spec.fqName?.asString()}'" + } } } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/TestOrSpecGradleRunConfigurationProducer.kt b/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/TestOrSpecGradleRunConfigurationProducer.kt index acf47ac0..dc6ec710 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/TestOrSpecGradleRunConfigurationProducer.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/run/gradle/TestOrSpecGradleRunConfigurationProducer.kt @@ -155,6 +155,10 @@ class TestOrSpecGradleRunConfigurationProducer : GradleRunConfigurationProducer( if (test != null) { // if we specified a test descriptor before, it needs to match for this configuration to be the same val descriptorArg = GradleUtils.getIncludeArg(configuration.settings.taskNames) ?: return false + if (test.isDataTest) { + val spec = element.enclosingSpec() + return spec?.fqName?.asString() == descriptorArg + } if (test.descriptorPath() == descriptorArg) return true } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/run/idea/TestPathRunConfigurationProducer.kt b/src/main/kotlin/io/kotest/plugin/intellij/run/idea/TestPathRunConfigurationProducer.kt index 04de0820..75c58f02 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/run/idea/TestPathRunConfigurationProducer.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/run/idea/TestPathRunConfigurationProducer.kt @@ -51,7 +51,10 @@ class TestPathRunConfigurationProducer : LazyRunConfigurationProducer = + setOf( + "withData", + "withContexts", + "withGivens", + "withWhens", + "withThens", + "withAnds" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private val contexts = listOf("Context", "context", "`Context`", "`context`") @@ -173,6 +184,7 @@ object BehaviorSpecStyle : SpecStyle { ?: element.tryXWhen() ?: element.tryThen() ?: element.tryXThen() + ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryThenWithConfig() else -> null } @@ -191,6 +203,36 @@ object BehaviorSpecStyle : SpecStyle { return setOf("OPEN_QUOTE", "DOT") } + /** + * For a BehaviorSpec we consider the following scenarios: + * + * context("test name") {} + * xcontext("test name") {} + * context("test name").config(...) {} + * xcontext("test name").config(...) {} + * given("test name") {} + * xgiven("test name") {} + * given("test name").config(...) {} + * xgiven("test name").config(...) {} + * when("test name") {} + * xwhen("test name") {} + * when("test name").config(...) {} + * xwhen("test name").config(...) {} + * then("test name") {} + * xthen("test name") {} + * then("test name").config(...) {} + * xthen("test name").config(...) {} + * and("test name") {} + * xand("test name") {} + * and("test name").config(...) {} + * xand("test name").config(...) {} + * withData(...) { } + * withContexts(...) { } + * withGivens(...) { } + * withWhens(...) { } + * withThens(...) { } + * withAnds(...) { } + */ override fun test(element: LeafPsiElement): Test? { val ktcall1 = element.ifOpenQuoteOfFunctionName(fnNames) if (ktcall1 != null) return test(ktcall1) @@ -198,6 +240,12 @@ object BehaviorSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecStyle.kt index 9a4b0e12..59b60ce3 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecStyle.kt @@ -10,6 +10,7 @@ import io.kotest.plugin.intellij.psi.extractLhsStringArgForDotExpressionWithRhsF import io.kotest.plugin.intellij.psi.extractStringArgForFunctionWithStringAndLambdaArgs import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator import io.kotest.plugin.intellij.psi.ifOpenQuoteOfFunctionName +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClassOrObject @@ -25,6 +26,14 @@ object DescribeSpecStyle : SpecStyle { return "describe(\"$name\") { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + "withContexts", + "withDescribes", + "withIts" + ) + private val fnNames = setOf("describe", "xdescribe", "context", "xcontext", "it", "xit") override fun isTestElement(element: PsiElement): Boolean = test(element) != null @@ -246,6 +255,7 @@ object DescribeSpecStyle : SpecStyle { ?: element.tryXDescribe() ?: element.tryContext() ?: element.tryXContent() + ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryDescribeWithConfig() ?: element.tryXDescribeWithConfig() @@ -261,6 +271,26 @@ object DescribeSpecStyle : SpecStyle { return setOf("OPEN_QUOTE", "DOT") } + /** + * For a DescribeSpec we consider the following scenarios: + * + * describe("test name") { } + * xdescribe("test name") { } + * context("test name") { } + * xcontext("test name") { } + * it("test name") { } + * xit("test name") { } + * describe("test name").config(...) {} + * xdescribe("test name").config(...) {} + * context("test name").config(...) {} + * xcontext("test name").config(...) {} + * it("test name").config(...) {} + * xit("test name").config(...) {} + * withData(...) { } + * withContexts(...) { } + * withDescribes(...) { } + * withIts(...) { } + */ override fun test(element: LeafPsiElement): Test? { val call = element.ifOpenQuoteOfFunctionName(fnNames) if (call != null) return test(call) @@ -268,6 +298,11 @@ object DescribeSpecStyle : SpecStyle { val dot = element.ifDotExpressionSeparator() if (dot != null) return test(dot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyle.kt index b4c831ce..7d53e718 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyle.kt @@ -10,6 +10,7 @@ import io.kotest.plugin.intellij.psi.extractLhsStringArgForDotExpressionWithRhsF import io.kotest.plugin.intellij.psi.extractStringArgForFunctionWithStringAndLambdaArgs import io.kotest.plugin.intellij.psi.ifCallExpressionLambdaOpenBrace import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClassOrObject @@ -25,6 +26,13 @@ object ExpectSpecStyle : SpecStyle { return "expect(\"$name\") { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + "withContexts", + "withExpects" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private fun locateParent(element: PsiElement): Test? { @@ -60,7 +68,7 @@ object ExpectSpecStyle : SpecStyle { override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.tryExpect() ?: element.tryContext() + is KtCallExpression -> element.tryExpect() ?: element.tryContext() ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryExpectWithConfig() else -> null } @@ -70,6 +78,17 @@ object ExpectSpecStyle : SpecStyle { return setOf("OPEN_QUOTE") } + /** + * For a ExpectSpec we consider the following scenarios: + * + * expect("test name") { } + * expect("test name").config(...) {} + * context("test name") {} + * context("test name").config(...) {} + * withData(...) { } + * withContexts(...) { } + * withExpects(...) { } + */ override fun test(element: LeafPsiElement): Test? { val ktcall = element.ifCallExpressionLambdaOpenBrace() if (ktcall != null) return test(ktcall) @@ -77,6 +96,12 @@ object ExpectSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyle.kt index 3e6fe6e1..7e015468 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyle.kt @@ -10,6 +10,7 @@ import io.kotest.plugin.intellij.psi.extractLhsStringArgForDotExpressionWithRhsF import io.kotest.plugin.intellij.psi.extractStringArgForFunctionWithStringAndLambdaArgs import io.kotest.plugin.intellij.psi.ifCallExpressionLambdaOpenBrace import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClassOrObject @@ -25,6 +26,13 @@ object FeatureSpecStyle : SpecStyle { return "feature(\"$name\") { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + "withFeatures", + "withScenarios" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private fun locateParent(element: PsiElement): Test? { @@ -67,7 +75,7 @@ object FeatureSpecStyle : SpecStyle { override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.tryScenario() ?: element.tryFeature() + is KtCallExpression -> element.tryScenario() ?: element.tryFeature() ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryFeatureWithConfig() ?: element.tryScenarioWithConfig() else -> null } @@ -77,6 +85,21 @@ object FeatureSpecStyle : SpecStyle { return setOf("OPEN_QUOTE") } + /** + * For a FeatureSpec we consider the following scenarios: + * + * feature("test name") { } + * xfeature("test name") { } + * feature("test name").config(...) {} + * xfeature("test name").config(...) {} + * scenario("test name") {} + * xscenario("test name") {} + * scenario("test name").config(...) {} + * xscenario("test name").config(...) {} + * withData(...) { } + * withFeatures(...) { } + * withScenarios(...) { } + */ override fun test(element: LeafPsiElement): Test? { val ktcall = element.ifCallExpressionLambdaOpenBrace() if (ktcall != null) return test(ktcall) @@ -84,6 +107,12 @@ object FeatureSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/FreeSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/FreeSpecStyle.kt index a81e3594..22de2729 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/FreeSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/FreeSpecStyle.kt @@ -12,6 +12,7 @@ import io.kotest.plugin.intellij.psi.extractStringLiteralFromLhsOfInfixFunction import io.kotest.plugin.intellij.psi.ifMinusOperator import io.kotest.plugin.intellij.psi.ifCallExpressionLhsStringOpenQuote import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtCallExpression @@ -28,6 +29,11 @@ object FreeSpecStyle : SpecStyle { return "\"$name\" { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private fun locateParent(element: PsiElement): Test? { @@ -79,7 +85,7 @@ object FreeSpecStyle : SpecStyle { override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.tryTest() + is KtCallExpression -> element.tryTest() ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryTestWithConfig() is KtBinaryExpression -> element.tryContainer() else -> null @@ -95,6 +101,7 @@ object FreeSpecStyle : SpecStyle { * * "test name" {} // a test * "test name" - {} // a container + * withData(...) { } */ override fun test(element: LeafPsiElement): Test? { val ktcall = element.ifCallExpressionLhsStringOpenQuote() @@ -106,6 +113,12 @@ object FreeSpecStyle : SpecStyle { val ktbinary = element.ifMinusOperator() if (ktbinary != null) return test(ktbinary) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/FunSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/FunSpecStyle.kt index 1ccebb3e..6226348b 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/FunSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/FunSpecStyle.kt @@ -10,6 +10,7 @@ import io.kotest.plugin.intellij.psi.extractLhsStringArgForDotExpressionWithRhsF import io.kotest.plugin.intellij.psi.extractStringArgForFunctionWithStringAndLambdaArgs import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator import io.kotest.plugin.intellij.psi.ifOpenQuoteOfFunctionName +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClassOrObject @@ -25,6 +26,13 @@ object FunSpecStyle : SpecStyle { return "test(\"$name\") { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + "withContexts", + "withTests" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private val fnNames = setOf("test", "xtest", "context", "xcontext") @@ -149,7 +157,7 @@ object FunSpecStyle : SpecStyle { */ override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.tryContext() ?: element.tryXContext() ?: element.tryTest() ?: element.tryXTest() + is KtCallExpression -> element.tryContext() ?: element.tryXContext() ?: element.tryTest() ?: element.tryXTest() ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryContextWithConfig() ?: element.tryXContextWithConfig() ?: element.tryTestWithConfig() ?: element.tryXTestWithConfig() else -> null @@ -171,6 +179,9 @@ object FunSpecStyle : SpecStyle { * xcontext("test name") {} * context("test name").config(...) {} * xcontext("test name").config(...) {} + * withData(...) { } + * withContexts(...) { } + * withTests(...) { } */ override fun test(element: LeafPsiElement): Test? { val call = element.ifOpenQuoteOfFunctionName(fnNames) @@ -179,6 +190,12 @@ object FunSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyle.kt index 7102ce3e..6658b526 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyle.kt @@ -10,6 +10,7 @@ import io.kotest.plugin.intellij.psi.extractLhsStringArgForDotExpressionWithRhsF import io.kotest.plugin.intellij.psi.extractStringArgForFunctionWithStringAndLambdaArgs import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator import io.kotest.plugin.intellij.psi.ifOpenQuoteOfFunctionName +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtClassOrObject @@ -25,6 +26,13 @@ object ShouldSpecStyle : SpecStyle { return "should(\"$name\") { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + "withContexts", + "withShoulds" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private val fnNames = setOf("should", "xshould", "context", "xcontext") @@ -122,7 +130,7 @@ object ShouldSpecStyle : SpecStyle { override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.tryKtCallExpression() + is KtCallExpression -> element.tryKtCallExpression() ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryKtDotQualifiedExpression() else -> null } @@ -133,7 +141,7 @@ object ShouldSpecStyle : SpecStyle { } /** - * For a FunSpec we consider the following scenarios: + * For a ShouldSpec we consider the following scenarios: * * should("test name") { } * xshould("test name") { } @@ -143,6 +151,9 @@ object ShouldSpecStyle : SpecStyle { * xcontext("test name") {} * context("test name").config(...) {} * xcontext("test name").config(...) {} + * withData(...) { } + * withContexts(...) { } + * withShoulds(...) { } */ override fun test(element: LeafPsiElement): Test? { val call = element.ifOpenQuoteOfFunctionName(fnNames) @@ -151,6 +162,12 @@ object ShouldSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/SpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/SpecStyle.kt index fd917137..0e1b5d99 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/SpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/SpecStyle.kt @@ -4,9 +4,13 @@ import com.intellij.psi.PsiElement import com.intellij.psi.impl.source.tree.LeafPsiElement import io.kotest.plugin.intellij.Test import io.kotest.plugin.intellij.TestElement +import io.kotest.plugin.intellij.TestName import io.kotest.plugin.intellij.TestType +import io.kotest.plugin.intellij.psi.enclosingKtClassOrObject +import io.kotest.plugin.intellij.psi.hasFunctionName import io.kotest.plugin.intellij.psi.isContainedInSpecificSpec import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtConstructorCalleeExpression import org.jetbrains.kotlin.psi.KtDeclarationModifierList import org.jetbrains.kotlin.psi.KtImportList @@ -47,6 +51,9 @@ interface SpecStyle { .mapNotNull { it.findAssociatedTest(element) } .firstOrNull() } + + // in future iterations this could change and be somehow saying running all data tests within the spec + val dataTestDefaultTestName: TestName = TestName(null, "All Spec Tests, including data tests", interpolated = false) } /** @@ -139,4 +146,27 @@ interface SpecStyle { * For example, a [FunSpec] would return a string like this: test("given name") { } */ fun generateTest(specName: String, name: String): String + + // TODO default will be removed if this POC is accepted and all other styles implement it + fun getDataTestMethodNames() : Set = emptySet() + + /** + * A test container of the form: + *``` + * withXXX(1, 2, 3) { } + * withXXX(listOf(1, 2, 3)) { } + * withXXX(nameFn = { "test $it" }, 1, 2, 3) { } + * ... + *``` + * plus any other withXXX permutation as per result of [getDataTestMethodNames]. + * + * Note: even tho we build a [Test], with some params, the runner will only read the [Test.isDataTest] boolean and determine it needs to run the whole spec. + */ + fun KtCallExpression.tryDataTest(): Test? { + val specClass = enclosingKtClassOrObject() ?: return null + + if (!hasFunctionName(getDataTestMethodNames().toList())) return null + + return Test(dataTestDefaultTestName, null, specClass, TestType.Container, xdisabled = false, psi = this, isDataTest = true) + } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyle.kt index 624beadc..e5325746 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyle.kt @@ -10,6 +10,7 @@ import io.kotest.plugin.intellij.psi.extractStringForStringExtensionFunctonWithR import io.kotest.plugin.intellij.psi.extractStringFromStringInvokeWithLambda import io.kotest.plugin.intellij.psi.ifCallExpressionLhsStringOpenQuote import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtDotQualifiedExpression @@ -28,6 +29,11 @@ object StringSpecStyle : SpecStyle { return "\"$name\" { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + ) + /** * A test of the form: * @@ -58,10 +64,11 @@ object StringSpecStyle : SpecStyle { * * "test name" { } * "test name".config(...) {} + * withData(...) { } */ override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.tryTest() + is KtCallExpression -> element.tryTest() ?: element.tryDataTest() is KtDotQualifiedExpression -> element.tryTestWithConfig() else -> null } @@ -76,6 +83,7 @@ object StringSpecStyle : SpecStyle { * * "test name" { } * "test name".config(...) {} + * withData(...) { } */ override fun test(element: LeafPsiElement): Test? { val ktcall = element.ifCallExpressionLhsStringOpenQuote() @@ -84,6 +92,12 @@ object StringSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/main/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyle.kt b/src/main/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyle.kt index d3835e0d..a74723b0 100644 --- a/src/main/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyle.kt +++ b/src/main/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyle.kt @@ -14,6 +14,7 @@ import io.kotest.plugin.intellij.psi.ifMinusOperator import io.kotest.plugin.intellij.psi.ifCallExpressionLhsStringOpenQuote import io.kotest.plugin.intellij.psi.ifDotExpressionSeparator import io.kotest.plugin.intellij.psi.ifOpenQuoteOfLhsArgOfIndexFunction +import io.kotest.plugin.intellij.psi.isDataTestMethodCall import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtCallExpression @@ -32,6 +33,13 @@ object WordSpecStyle : SpecStyle { return "\"$name\" should { }" } + override fun getDataTestMethodNames(): Set = + setOf( + "withData", + "withWhens", + "withShoulds" + ) + override fun isTestElement(element: PsiElement): Boolean = test(element) != null private fun PsiElement.locateParentWhen(): Test? { @@ -123,7 +131,7 @@ object WordSpecStyle : SpecStyle { override fun test(element: PsiElement): Test? { return when (element) { - is KtCallExpression -> element.trySubject() + is KtCallExpression -> element.trySubject() ?: element.tryDataTest() is KtBinaryExpression -> (element.tryShould() ?: element.tryWhen()) is KtDotQualifiedExpression -> element.trySubjectWithConfig() else -> null @@ -134,6 +142,21 @@ object WordSpecStyle : SpecStyle { return setOf("OPEN_QUOTE") } + /** + * For a WordSpec we consider the following scenarios: + * + * should("test name") { } + * xshould("test name") { } + * should("test name").config(...) {} + * xshould("test name").config(...) {} + * when("test name") {} + * xwhen("test name") {} + * when("test name").config(...) {} + * xwhen("test name").config(...) {} + * withData(...) { } + * withWhens(...) { } + * withShoulds(...) { } + */ override fun test(element: LeafPsiElement): Test? { val ktcall = element.ifCallExpressionLhsStringOpenQuote() if (ktcall != null) return test(ktcall) @@ -147,6 +170,12 @@ object WordSpecStyle : SpecStyle { val ktdot = element.ifDotExpressionSeparator() if (ktdot != null) return test(ktdot) + // try to find Data Test Method by finding lambda openings + val dataMethodCall = element.isDataTestMethodCall(getDataTestMethodNames()) + if (dataMethodCall != null) { + return test(dataMethodCall) + } + return null } } diff --git a/src/test/kotlin/io/kotest/plugin/intellij/intentions/BangIntentionTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/intentions/BangIntentionTest.kt index b209f58f..85deb18a 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/intentions/BangIntentionTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/intentions/BangIntentionTest.kt @@ -20,19 +20,19 @@ class BangIntentionTest : LightJavaCodeInsightFixtureTestCase() { "/behaviorspec.kt", "/io/kotest/core/spec/style/specs.kt" ) - editor.moveCaret(265) + editor.moveCaret(300) val intention = myFixture.findSingleIntention("Add/Remove bang to test name") intention.familyName shouldBe "Add/Remove bang to test name" WriteCommandAction.runWriteCommandAction(project) { intention.invoke(project, editor, file) } - file.findElementAt(265)?.text shouldBe "!another test" + file.findElementAt(300)?.text shouldBe "!another test" WriteCommandAction.runWriteCommandAction(project) { intention.invoke(project, editor, file) } - file.findElementAt(265)?.text shouldBe "another test" + file.findElementAt(300)?.text shouldBe "another test" } fun testIntentionShouldOnlyBeAvailableOnStrings() { diff --git a/src/test/kotlin/io/kotest/plugin/intellij/psi/ClassTests.kt b/src/test/kotlin/io/kotest/plugin/intellij/psi/ClassTests.kt index 8469d844..0c4b7f2a 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/psi/ClassTests.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/psi/ClassTests.kt @@ -41,7 +41,7 @@ class ClassTests : LightJavaCodeInsightFixtureTestCase() { "/io/kotest/core/spec/style/specs.kt" ) - val element = psiFile[0].elementAtLine(21) + val element = psiFile[0].elementAtLine(22) element.shouldNotBeNull() val ktclass = element.enclosingKtClass() ktclass.shouldNotBeNull() diff --git a/src/test/kotlin/io/kotest/plugin/intellij/psi/OffsetsTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/psi/OffsetsTest.kt index 0b7df65e..bd07d65c 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/psi/OffsetsTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/psi/OffsetsTest.kt @@ -19,18 +19,18 @@ class OffsetsTest : LightJavaCodeInsightFixtureTestCase() { fun testLineOffsets() { val psiFile = myFixture.configureByFile("/funspec.kt") - val offsets = psiFile.offsetForLine(21) + val offsets = psiFile.offsetForLine(22) offsets.shouldNotBeNull() - offsets.first shouldBe 324 - offsets.last shouldBe 353 + offsets.first shouldBe 359 + offsets.last shouldBe 388 } fun testFindElementForAGivenLine() { val psiFile = myFixture.configureByFile("/funspec.kt") - val element: PsiElement? = psiFile.elementAtLine(24) + val element: PsiElement? = psiFile.elementAtLine(25) element.shouldNotBeNull() element.node.shouldBeInstanceOf() - element.startOffset shouldBe 369 - element.endOffset shouldBe 373 + element.startOffset shouldBe 404 + element.endOffset shouldBe 408 } } diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/BehaviorSpecRunMarkerTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/BehaviorSpecRunMarkerTest.kt index 71550024..93bb71ca 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/BehaviorSpecRunMarkerTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/BehaviorSpecRunMarkerTest.kt @@ -25,65 +25,67 @@ class BehaviorSpecRunMarkerTest : LightJavaCodeInsightFixtureTestCase() { val gutters = myFixture.findAllGutters() println(gutters.map { it.tooltipText }.joinToString("\n")) - gutters.size shouldBe 34 + gutters.size shouldBe 35 val expected = listOf( - Gutter("Run BehaviorSpecExample", 91, AllIcons.RunConfigurations.TestState.Run_run), - Gutter("Run a given", 159), - Gutter("Run a given a when", 188), - Gutter("Run a given a when a test", 217), - Gutter("Run a given a when another test", 260), - Gutter("Disabled - a given a when a disabled then", 310, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - a given disabled when", 371, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run BehaviorSpecExample", 126, AllIcons.RunConfigurations.TestState.Run_run), + Gutter("Run a given", 194), + Gutter("Run a given a when", 223), + Gutter("Run a given a when a test", 252), + Gutter("Run a given a when another test", 295), + Gutter("Disabled - a given a when a disabled then", 345, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - a given disabled when", 406, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - a given disabled when this then should be disabled from its parent", - 407, + 442, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - a given disabled when this then should be disabled with config", - 531, + 566, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Run a given an and", 596), - Gutter("Run a given an and a when", 627), - Gutter("Run a given an and a when a test", 659), - Gutter("Run a given an and an and in an and", 718), - Gutter("Run a given an and an and in an and a test", 760), - Gutter("Disabled - a given an and disabled when", 821, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run a given an and", 631), + Gutter("Run a given an and a when", 662), + Gutter("Run a given an and a when a test", 694), + Gutter("Run a given an and an and in an and", 753), + Gutter("Run a given an and an and in an and a test", 795), + Gutter("Disabled - a given an and disabled when", 856, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - a given an and disabled when this then should be disabled by nesting", - 860, + 895, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - a given an and disabled when an xdisabled then", - 943, + 978, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - a given disabled and", 1022, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - a given disabled and a nested when", 1059, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - a given disabled and a nested when a test", 1098, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - disabled given", 1173, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - disabled given disabled when", 1207, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - a given disabled and", 1057, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - a given disabled and a nested when", 1094, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - a given disabled and a nested when a test", 1133, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled given", 1208, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled given disabled when", 1242, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - disabled given disabled when a disabled then", - 1243, + 1278, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - disabled given disabled and", 1302, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - disabled given disabled and a test", 1337, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - disabled given", 1395, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - disabled given a nested then", 1429, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run a context", 1472), - Gutter("Run a context a nested given", 1499), - Gutter("Run a context a nested given a when", 1535), - Gutter("Run a context a nested given a when a test", 1564), - Gutter("Disabled - a context disabled given", 1622, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - a context disabled given a disabled when", 1656, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - a context disabled given a disabled when a disabled test", 1694, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled given disabled and", 1337, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled given disabled and a test", 1372, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled given", 1430, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled given a nested then", 1464, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run a context", 1507), + Gutter("Run a context a nested given", 1534), + Gutter("Run a context a nested given a when", 1570), + Gutter("Run a context a nested given a when a test", 1599), + Gutter("Disabled - a context disabled given", 1657, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - a context disabled given a disabled when", 1691, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - a context disabled given a disabled when a disabled test", 1729, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run All Spec Tests, including data tests", 1815), ) + expected.size shouldBe gutters.size assertSoftly { diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecRunMarkerTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecRunMarkerTest.kt index 4b883f4d..663d404a 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecRunMarkerTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/DescribeSpecRunMarkerTest.kt @@ -33,82 +33,83 @@ class DescribeSpecRunMarkerTest : LightJavaCodeInsightFixtureTestCase() { val gutters = myFixture.findAllGutters() val expected = listOf( - Gutter("Run DescribeSpecExample", 91, AllIcons.RunConfigurations.TestState.Run_run), - Gutter("Run describe block", 161), - Gutter("Run describe block it block", 193), - Gutter("Disabled - describe block xit block", 256, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run describe block it with config", 336), - Gutter("Disabled - describe block xit block with config", 436, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run describe block nested describe block", 517), - Gutter("Run describe block nested describe block it block", 559), - Gutter("Disabled - describe block nested xdescribe block", 645, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run DescribeSpecExample", 126, AllIcons.RunConfigurations.TestState.Run_run), + Gutter("Run describe block", 196), + Gutter("Run describe block it block", 228), + Gutter("Disabled - describe block xit block", 291, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run describe block it with config", 371), + Gutter("Disabled - describe block xit block with config", 471, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run describe block nested describe block", 552), + Gutter("Run describe block nested describe block it block", 594), + Gutter("Disabled - describe block nested xdescribe block", 680, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - describe block nested xdescribe block it block", - 688, + 723, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - xdescribe block", 779, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdescribe block it block", 812, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdescribe block xit block", 875, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdescribe block it with config", 955, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdescribe block xit block with config", 1055, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdescribe block nested describe block", 1136, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block", 814, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block it block", 847, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block xit block", 910, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block it with config", 990, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block xit block with config", 1090, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block nested describe block", 1171, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - xdescribe block nested describe block it block", - 1178, + 1213, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - xdescribe block nested xdescribe block", 1264, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe block nested xdescribe block", 1299, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - xdescribe block nested xdescribe block it block", - 1307, + 1342, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Run context block", 1396), - Gutter("Run context block nested context block", 1432), - Gutter("Run context block nested context block nested describe block", 1479), - Gutter("Run context block nested context block nested describe block it block", 1524), + Gutter("Run context block", 1431), + Gutter("Run context block nested context block", 1467), + Gutter("Run context block nested context block nested describe block", 1514), + Gutter("Run context block nested context block nested describe block it block", 1559), Gutter( "Disabled - context block nested context block nested xdescribe block", - 1622, + 1657, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - context block nested context block nested xdescribe block it block", - 1668, + 1703, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - context block nested xcontext block", 1773, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - context block nested xcontext block", 1808, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - context block nested xcontext block nested describe block", - 1821, + 1856, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - context block nested xcontext block nested describe block it block", - 1866, + 1901, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - context block nested xcontext block nested xdescribe block", - 1964, + 1999, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - context block nested xcontext block nested xdescribe block it block", - 2010, + 2045, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Run context block nested describe block", 2115), - Gutter("Run context block nested describe block it block", 2157), - Gutter("Run describe with config", 2270), - Gutter("Run describe with config it block", 2308), - Gutter("Disabled - xdescribe with config", 2406, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdescribe with config it block", 2444, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run context with config", 2538), - Gutter("Run context with config nested describe with config", 2612), - Gutter("Run context with config nested describe with config it block", 2653), - Gutter("Disabled - xcontext with config", 2766, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run context block nested describe block", 2150), + Gutter("Run context block nested describe block it block", 2192), + Gutter("Run describe with config", 2305), + Gutter("Run describe with config it block", 2343), + Gutter("Disabled - xdescribe with config", 2441, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdescribe with config it block", 2479, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run context with config", 2573), + Gutter("Run context with config nested describe with config", 2647), + Gutter("Run context with config nested describe with config it block", 2688), + Gutter("Disabled - xcontext with config", 2801, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run All Spec Tests, including data tests", 2866), ) expected.size shouldBe gutters.size diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyleTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyleTest.kt index d72286aa..9aac0a34 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyleTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/ExpectSpecStyleTest.kt @@ -6,6 +6,7 @@ import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import io.kotest.matchers.shouldBe import io.kotest.plugin.intellij.testMode import java.nio.file.Paths +import kotlin.collections.get class ExpectSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { @@ -23,34 +24,38 @@ class ExpectSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { ) val gutters = myFixture.findAllGutters() - gutters.size shouldBe 7 + gutters.size shouldBe 8 gutters[0].icon shouldBe AllIcons.RunConfigurations.TestState.Run_run gutters[0].tooltipText shouldBe "Run ExpectSpecExample" - (gutters[0] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 87 + (gutters[0] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 122 gutters[1].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[1].tooltipText shouldBe "Run some context" - (gutters[1] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 165 + (gutters[1] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 200 gutters[2].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[2].tooltipText shouldBe "Run some context some test" - (gutters[2] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 193 + (gutters[2] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 228 gutters[3].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[3].tooltipText shouldBe "Run some context some test with config" - (gutters[3] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 261 + (gutters[3] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 296 gutters[4].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[4].tooltipText shouldBe "Run some context another nested context" - (gutters[4] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 357 + (gutters[4] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 392 gutters[5].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[5].tooltipText shouldBe "Run some context another nested context some test" - (gutters[5] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 387 + (gutters[5] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 422 gutters[6].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[6].tooltipText shouldBe "Run some context another nested context some test with config" - (gutters[6] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 461 + (gutters[6] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 496 + + gutters[7].icon shouldBe AllIcons.RunConfigurations.TestState.Run + gutters[7].tooltipText shouldBe "Run All Spec Tests, including data tests" + (gutters[7] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 599 } } diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyleTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyleTest.kt index 06ad1f94..688fb58f 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyleTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/FeatureSpecStyleTest.kt @@ -6,6 +6,7 @@ import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import io.kotest.matchers.shouldBe import io.kotest.plugin.intellij.testMode import java.nio.file.Paths +import kotlin.collections.get class FeatureSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { @@ -23,51 +24,55 @@ class FeatureSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { ) val gutters = myFixture.findAllGutters() - gutters.size shouldBe 11 + gutters.size shouldBe 12 gutters[0].icon shouldBe AllIcons.RunConfigurations.TestState.Run_run gutters[0].tooltipText shouldBe "Run FeatureSpecExample" - (gutters[0] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 144 + (gutters[0] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 179 gutters[1].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[1].tooltipText shouldBe "Run no scenario" - (gutters[1] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 227 + (gutters[1] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 262 gutters[2].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[2].tooltipText shouldBe "Run some feature" - (gutters[2] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 299 + (gutters[2] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 334 gutters[3].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[3].tooltipText shouldBe "Run some feature some scenario" - (gutters[3] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 336 + (gutters[3] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 371 gutters[4].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[4].tooltipText shouldBe "Run another feature" - (gutters[4] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 425 + (gutters[4] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 460 gutters[5].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[5].tooltipText shouldBe "Run another feature test with config" - (gutters[5] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 464 + (gutters[5] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 499 gutters[6].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[6].tooltipText shouldBe "Run a feature with config" - (gutters[6] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 596 + (gutters[6] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 631 gutters[7].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[7].tooltipText shouldBe "Run this feature" - (gutters[7] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 706 + (gutters[7] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 741 gutters[8].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[8].tooltipText shouldBe "Run this feature has nested feature contexts" - (gutters[8] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 756 + (gutters[8] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 791 gutters[9].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[9].tooltipText shouldBe "Run this feature has nested feature contexts test without config" - (gutters[9] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 802 + (gutters[9] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 837 gutters[10].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[10].tooltipText shouldBe "Run this feature has nested feature contexts test with config" - (gutters[10] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 895 + (gutters[10] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 930 + + gutters[11].icon shouldBe AllIcons.RunConfigurations.TestState.Run + gutters[11].tooltipText shouldBe "Run All Spec Tests, including data tests" + (gutters[11] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 1070 } fun testMethodGeneration() { diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/FreeSpecRunMarkerTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/FreeSpecRunMarkerTest.kt index fd7d2dba..991eb5f5 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/FreeSpecRunMarkerTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/FreeSpecRunMarkerTest.kt @@ -24,39 +24,43 @@ class FreeSpecRunMarkerTest : LightJavaCodeInsightFixtureTestCase() { val gutters = myFixture.findAllGutters() println(gutters.map { it.tooltipText }.joinToString("\n")) - gutters.size shouldBe 8 + gutters.size shouldBe 9 gutters[0].icon shouldBe AllIcons.RunConfigurations.TestState.Run_run gutters[0].tooltipText shouldBe "Run FreeSpecExample" - (gutters[0] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 87 + (gutters[0] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 122 gutters[1].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[1].tooltipText shouldBe "Run some context" - (gutters[1] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 152 + (gutters[1] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 187 gutters[2].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[2].tooltipText shouldBe "Run some context more context" - (gutters[2] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 177 + (gutters[2] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 212 gutters[3].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[3].tooltipText shouldBe "Run some context more context as many as you want" - (gutters[3] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 211 + (gutters[3] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 246 gutters[4].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[4].tooltipText shouldBe "Run some context more context as many as you want then a test" - (gutters[4] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 225 + (gutters[4] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 260 gutters[5].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[5].tooltipText shouldBe "Run another context" - (gutters[5] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 324 + (gutters[5] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 359 gutters[6].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[6].tooltipText shouldBe "Run another context a test with config" - (gutters[6] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 354 + (gutters[6] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 389 gutters[7].icon shouldBe AllIcons.RunConfigurations.TestState.Run gutters[7].tooltipText shouldBe "Run a test without a context block" - (gutters[7] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 399 + (gutters[7] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 434 + + gutters[8].icon shouldBe AllIcons.RunConfigurations.TestState.Run + gutters[8].tooltipText shouldBe "Run All Spec Tests, including data tests" + (gutters[8] as LineMarkerInfo.LineMarkerGutterIconRenderer<*>).lineMarkerInfo.startOffset shouldBe 505 } fun testMethodGeneration() { diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/FunSpecRunMarkerTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/FunSpecRunMarkerTest.kt index 23134615..f366c495 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/FunSpecRunMarkerTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/FunSpecRunMarkerTest.kt @@ -27,66 +27,69 @@ class FunSpecRunMarkerTest : LightJavaCodeInsightFixtureTestCase() { val gutters = myFixture.findAllGutters() val expected = listOf( - Gutter("Run FunSpecExampleTest", 76, AllIcons.RunConfigurations.TestState.Run_run), - Gutter("Run a test", 122), - Gutter("Run a test with config", 169), - Gutter("Disabled - an xtest", 210, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - an xtest with config", 262, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run some context", 305), - Gutter("Run some context a nested test", 335), - Gutter("Run some context a nested test with config", 402), - Gutter("Disabled - some context a nested xtest", 449, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - some context a nested xtest with config", 519, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run some context a nested context", 568), - Gutter("Run some context a nested context a test", 605), + Gutter("Run FunSpecExampleTest", 111, AllIcons.RunConfigurations.TestState.Run_run), + Gutter("Run a test", 157), + Gutter("Run a test with config", 204), + Gutter("Disabled - an xtest", 245, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - an xtest with config", 297, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run some context", 340), + Gutter("Run some context a nested test", 370), + Gutter("Run some context a nested test with config", 437), + Gutter("Disabled - some context a nested xtest", 484, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - some context a nested xtest with config", 554, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run some context a nested context", 603), + Gutter("Run some context a nested context a test", 640), Gutter( "Disabled - some context a nested context a nested xcontext", - 647, + 682, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - some context a nested context a nested xcontext a test", - 687, + 722, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - some context a nested context a nested xcontext a nested context", - 733, + 768, AllIcons.RunConfigurations.TestIgnored ), Gutter( "Disabled - some context a nested context a nested xcontext a nested context a test", - 775, + 810, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - some context an xcontext", 853, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - some context an xcontext a test", 884, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - some context an xcontext an xtest", 922, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - some context an xcontext a nested xcontext", 966, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - some context an xcontext", 888, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - some context an xcontext a test", 919, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - some context an xcontext an xtest", 957, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - some context an xcontext a nested xcontext", 1001, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - some context an xcontext a nested xcontext a test", - 1006, + 1041, AllIcons.RunConfigurations.TestIgnored ), - Gutter("Disabled - an xcontext", 1069, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - an xcontext a test", 1097, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - an xcontext a nested xcontext", 1131, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - an xcontext a nested xcontext a test", 1168, AllIcons.RunConfigurations.TestIgnored), - Gutter("Run context with config", 1238), - Gutter("Run context with config a test inside a context with config", 1275), - Gutter("Disabled - xcontext with config", 1365, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - an xcontext", 1104, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - an xcontext a test", 1132, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - an xcontext a nested xcontext", 1166, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - an xcontext a nested xcontext a test", 1203, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run context with config", 1273), + Gutter("Run context with config a test inside a context with config", 1310), + Gutter("Disabled - xcontext with config", 1400, AllIcons.RunConfigurations.TestIgnored), Gutter( "Disabled - xcontext with config a test inside an xcontext with config", - 1402, + 1437, AllIcons.RunConfigurations.TestIgnored ), // Previously the PSI text was fetched which contains the raw text entered, not parsed string, which means it would include the backslashes as well. // See https://github.com/kotest/kotest/issues/3078 - Gutter("""Run name containing "escaped quotes"""", 1467), + Gutter("""Run name containing "escaped quotes"""", 1502), + Gutter("Run All Spec Tests, including data tests", 1575), ) -// gutters.size shouldBe expected.size + // not sure why this works in gradle runner but not in IDE + // going to leave it here and if it gives you trouble comment it out while you test stuff locally + gutters.size shouldBe expected.size assertSoftly { expected.withIndex().forEach { (index, a) -> diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyleTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyleTest.kt index 30167e48..1805df5b 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyleTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/ShouldSpecStyleTest.kt @@ -25,24 +25,25 @@ class ShouldSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { val gutters = myFixture.findAllGutters() println(gutters.map { it.tooltipText }.joinToString("\n")) - gutters.size shouldBe 15 + gutters.size shouldBe 16 val expected = listOf( - Gutter("Run ShouldSpecExample", 91, AllIcons.RunConfigurations.TestState.Run_run), - Gutter("Run top level test", 155), - Gutter("Run top level test with config", 247), - Gutter("Run some context", 317), - Gutter("Run some context top level test", 351), - Gutter("Run some context top level test with config", 452), - Gutter("Run some context 2", 536), - Gutter("Run some context 2 some nested context", 573), - Gutter("Run some context 2 some nested context top level test", 617), - Gutter("Run some context 2 some nested context top level test with config", 727), - Gutter("Run a context with config", 852), - Gutter("Run a context with config a should", 894), - Gutter("Disabled - an xcontext with config", 958, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - an xcontext with config a should", 1000, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - xdisabled should", 1037, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run ShouldSpecExample", 126, AllIcons.RunConfigurations.TestState.Run_run), + Gutter("Run top level test", 190), + Gutter("Run top level test with config", 282), + Gutter("Run some context", 352), + Gutter("Run some context top level test", 386), + Gutter("Run some context top level test with config", 487), + Gutter("Run some context 2", 571), + Gutter("Run some context 2 some nested context", 608), + Gutter("Run some context 2 some nested context top level test", 652), + Gutter("Run some context 2 some nested context top level test with config", 762), + Gutter("Run a context with config", 887), + Gutter("Run a context with config a should", 929), + Gutter("Disabled - an xcontext with config", 993, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - an xcontext with config a should", 1035, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - xdisabled should", 1072, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run All Spec Tests, including data tests", 1133), ) gutters.size shouldBe expected.size diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyleTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyleTest.kt index 462521d2..b6ebdc30 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyleTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/StringSpecStyleTest.kt @@ -24,12 +24,13 @@ class StringSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { ) val gutters = myFixture.findAllGutters() - gutters.size shouldBe 3 + gutters.size shouldBe 4 val expected = listOf( - Gutter("Run StringSpecExample", 91, AllIcons.RunConfigurations.TestState.Run_run), - Gutter("Run test", 145), - Gutter("Run test with config", 201), + Gutter("Run StringSpecExample", 126, AllIcons.RunConfigurations.TestState.Run_run), + Gutter("Run test", 180), + Gutter("Run test with config", 236), + Gutter("Run All Spec Tests, including data tests", 299), ) expected.size shouldBe gutters.size diff --git a/src/test/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyleTest.kt b/src/test/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyleTest.kt index f3fab981..a9ad457d 100644 --- a/src/test/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyleTest.kt +++ b/src/test/kotlin/io/kotest/plugin/intellij/styles/WordSpecStyleTest.kt @@ -24,19 +24,20 @@ class WordSpecStyleTest : LightJavaCodeInsightFixtureTestCase() { ) val gutters = myFixture.findAllGutters() - gutters.size shouldBe 10 + gutters.size shouldBe 11 val expected = listOf( - Gutter("Run WordSpecExample", 87, AllIcons.RunConfigurations.TestState.Run_run), - Gutter("Run some should context", 137), - Gutter("Run some should context test something", 174), - Gutter("Run some should context test something with config", 256), - Gutter("Run with capital When", 302), - Gutter("Run with capital When and capital Should", 335), - Gutter("Run with capital When test something", 373), - Gutter("Run with capital When test something with config", 428), - Gutter("Disabled - with capital When disabled should", 480, AllIcons.RunConfigurations.TestIgnored), - Gutter("Disabled - disabled when", 529, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run WordSpecExample", 122, AllIcons.RunConfigurations.TestState.Run_run), + Gutter("Run some should context", 172), + Gutter("Run some should context test something", 209), + Gutter("Run some should context test something with config", 291), + Gutter("Run with capital When", 337), + Gutter("Run with capital When and capital Should", 370), + Gutter("Run with capital When test something", 408), + Gutter("Run with capital When test something with config", 463), + Gutter("Disabled - with capital When disabled should", 515, AllIcons.RunConfigurations.TestIgnored), + Gutter("Disabled - disabled when", 564, AllIcons.RunConfigurations.TestIgnored), + Gutter("Run All Spec Tests, including data tests", 625), ) gutters.size shouldBe expected.size diff --git a/src/test/resources/behaviorspec.kt b/src/test/resources/behaviorspec.kt index 761c5380..4d819269 100644 --- a/src/test/resources/behaviorspec.kt +++ b/src/test/resources/behaviorspec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.behavior import io.kotest.core.spec.style.BehaviorSpec +import io.kotest.datatest.withData class BehaviorSpecExample : BehaviorSpec() { @@ -71,4 +72,7 @@ class BehaviorSpecExample : BehaviorSpec() { } } } + withData(1, 2, 3, 4, 5) { value -> + // test here + } } diff --git a/src/test/resources/describespec.kt b/src/test/resources/describespec.kt index 10278caf..77bcf8ea 100644 --- a/src/test/resources/describespec.kt +++ b/src/test/resources/describespec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.describe import io.kotest.core.spec.style.DescribeSpec +import io.kotest.datatest.withData class DescribeSpecExample : DescribeSpec() { init { @@ -102,6 +103,10 @@ class DescribeSpecExample : DescribeSpec() { } xcontext("xcontext with config").config(enabled = true) { } + + withData(1, 2, 3, 4, 5) { value -> + // test here + } } } diff --git a/src/test/resources/expectspec.kt b/src/test/resources/expectspec.kt index 2d10b79d..33854ca6 100644 --- a/src/test/resources/expectspec.kt +++ b/src/test/resources/expectspec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.expect import io.kotest.core.spec.style.ExpectSpec +import io.kotest.datatest.withData class ExpectSpecExample : ExpectSpec() { init { @@ -20,5 +21,9 @@ class ExpectSpecExample : ExpectSpec() { } } } + + withData(1, 2, 3, 4, 5) { value -> + // test here + } } } diff --git a/src/test/resources/featurespec.kt b/src/test/resources/featurespec.kt index 61ca2c70..ca91efde 100644 --- a/src/test/resources/featurespec.kt +++ b/src/test/resources/featurespec.kt @@ -2,6 +2,7 @@ package com.sksamuel.kotest.specs.feature import io.kotest.core.spec.style.FeatureSpec import io.kotest.matchers.comparables.shouldBeLessThan +import io.kotest.datatest.withData class FeatureSpecExample : FeatureSpec() { init { @@ -36,5 +37,8 @@ class FeatureSpecExample : FeatureSpec() { } } } + withData(1, 2, 3, 4, 5) { value -> + // test here + } } } diff --git a/src/test/resources/freespec.kt b/src/test/resources/freespec.kt index 132e4eaf..c2336156 100644 --- a/src/test/resources/freespec.kt +++ b/src/test/resources/freespec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.freespec import io.kotest.core.spec.style.FreeSpec +import io.kotest.datatest.withData class FreeSpecExample : FreeSpec() { init { @@ -20,5 +21,9 @@ class FreeSpecExample : FreeSpec() { } "a test without a context block" { } + + withData(1, 2, 3, 4, 5) { value -> + // test here + } } -} \ No newline at end of file +} diff --git a/src/test/resources/funspec.kt b/src/test/resources/funspec.kt index 0442979b..fec3aa10 100644 --- a/src/test/resources/funspec.kt +++ b/src/test/resources/funspec.kt @@ -1,6 +1,7 @@ package io.kotest.samples.gradle import io.kotest.core.spec.style.FunSpec +import io.kotest.datatest.withData class FunSpecExampleTest : FunSpec({ @@ -79,4 +80,8 @@ class FunSpecExampleTest : FunSpec({ test("name containing \"escaped quotes\"") { } + + withData(1, 2, 3, 4, 5) { value -> + // test here + } }) diff --git a/src/test/resources/shouldspec.kt b/src/test/resources/shouldspec.kt index 9f2695b1..ce44e099 100644 --- a/src/test/resources/shouldspec.kt +++ b/src/test/resources/shouldspec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.shouldspec import io.kotest.core.spec.style.ShouldSpec +import io.kotest.datatest.withData class ShouldSpecExample : ShouldSpec() { init { @@ -37,5 +38,9 @@ class ShouldSpecExample : ShouldSpec() { xshould("xdisabled should"){ } + + withData(1, 2, 3, 4, 5) { value -> + // test here + } } } diff --git a/src/test/resources/stringspec.kt b/src/test/resources/stringspec.kt index e81403e9..e52f5c96 100644 --- a/src/test/resources/stringspec.kt +++ b/src/test/resources/stringspec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.stringspec import io.kotest.core.spec.style.StringSpec +import io.kotest.datatest.withData class StringSpecExample : StringSpec() { init { @@ -10,5 +11,8 @@ class StringSpecExample : StringSpec() { "test with config".config(enabled = false) { } + withData(1, 2, 3, 4, 5) { value -> + // test here + } } } diff --git a/src/test/resources/wordspec.kt b/src/test/resources/wordspec.kt index 12039a08..a40736cd 100644 --- a/src/test/resources/wordspec.kt +++ b/src/test/resources/wordspec.kt @@ -1,6 +1,7 @@ package com.sksamuel.kotest.specs.wordspec import io.kotest.core.spec.style.WordSpec +import io.kotest.datatest.withData class WordSpecExample : WordSpec() { init { @@ -27,5 +28,8 @@ class WordSpecExample : WordSpec() { } + withData(1, 2, 3, 4, 5) { value -> + // test here + } } }