https://kotlinlang.org logo
#kotest
Title
# kotest
t

tim

06/02/2021, 12:01 PM
Is anyone currently using https://github.com/kotest/kotest-extensions-gherkin with success? I'm getting an error when trying to run my skeleton test but since there are no docs I'm not sure if im doing it correctly.
Test:
Copy code
package glimpse.e2e

import io.kotest.core.spec.style.FreeSpec
import io.kotest.extensions.gherkin.GherkinExtension
import io.kotest.matchers.booleans.shouldBeTrue

class HelloWorld : FreeSpec({
    extension(GherkinExtension("HelloWorld.feature"))

    "its alive" - {
        "A" - {
            "B" {
                true.shouldBeTrue()
            }
        }
    }
})
s

sam

06/02/2021, 12:19 PM
@LeoColman
l

LeoColman

06/02/2021, 12:54 PM
I am using it successfully. Let me check your stacktrace
🙏 1
t

tim

06/02/2021, 12:54 PM
does it matter what kotest version i'm using (currently on 4.6.0)?
l

LeoColman

06/02/2021, 12:55 PM
It doesn't. Could you show me the classpath? How are your resources organized?
at least it shouldn't xD
t

tim

06/02/2021, 12:56 PM
2 mo i was trying to follow the cucumber guide so will need to roll back some changes
l

LeoColman

06/02/2021, 12:57 PM
I'd just like to make sure that "HelloWorld.feature" is at the path we expect it to be
It should be directly under
resources
directory from your test source set. You can also provide relative path
t

tim

06/02/2021, 12:57 PM
its in
src/test/kotlin/resources/HelloWorld.feature
l

LeoColman

06/02/2021, 12:57 PM
If having files from outside your project (eg. via absolute path) is something you need, we would need to tweak the extension a little bit, as currently it reads from classpath
Well, it seems correct. Let me check some more th ings
t

tim

06/02/2021, 12:58 PM
having them inside the resources folder works fine for us ... we're creating a project just for e2e tests so hoping to not be pulling in / minimizing external dependencies
l

LeoColman

06/02/2021, 12:59 PM
The big deal here is line 30 from `GherkinExtension`:
javaClass.classLoader.getResourceAsStream(featureFilePath)!!.bufferedReader().readText()
Could you check if youcan load the file this way?
t

tim

06/02/2021, 1:01 PM
ya that fails
heres the folder structure for context
s

sam

06/02/2021, 1:02 PM
Try with a leading slash
Eg /my.feature
t

tim

06/02/2021, 1:03 PM
no joy
l

LeoColman

06/02/2021, 1:10 PM
Just for testing, could you place your file in
src/main/resources
? I'm trying to check something with the classpath
t

tim

06/02/2021, 1:12 PM
yep
okay that works
doesn't work in
src/main/kotlin/resources
though
s

sam

06/02/2021, 1:14 PM
You can't put resources inside the Kotlin folder and then use /
They should be in src/mainortest/language
t

tim

06/02/2021, 1:17 PM
okay so this is working now
s

sam

06/02/2021, 1:18 PM
src/test/resources should work too
t

tim

06/02/2021, 1:19 PM
yep all good
thanks for your help 🙏
l

LeoColman

06/02/2021, 1:20 PM
Great! If any more problems come up, feel free to ping me 😄
t

tim

06/02/2021, 1:22 PM
while you here ... should an earlier fail stop subsequent test from running? I.e. something like this
l

LeoColman

06/02/2021, 1:24 PM
Not at the moment, no. The extension currently only verifies if all test names are present in your file
t

tim

06/02/2021, 1:25 PM
cool
3 Views