How do you nest Kotlin tests in packages in intelliJ? - kotlin

I have a new Kotlin project in intelliJ building with Gradle. I am using JUnit5 as a testing scheme.
Initially when writing my tests, they were executable from intelliJ using the green arrow. After writing some more tests, I decided to start organizing my tests into subpackages. As soon as I moved a test into a subpackage, the test began to fail with an error
No tests found for given includes: [PackageName.FileName.TestName]
If I look at the gradle run configuration of that test, I see
:test --tests "PackageName.FileName.TestName"
Running this command directly with gradle also fails. If I run
./gradlew :test my test runs succesfully. If I omit the package name in the gradle command, ./gradlew :test --tests "FileName.TestName" it runs succesfully. How can I get gradle to recognize the packagename? Or as a worse solution, how can I get intelliJ to generate the gradle run configurations without the package name?

Related

Cucumber kotlin : IllegalStateException when launching test via Intellij

I am trying to launch a cucumber (written in kotlin) via intellij.
I have a step definition class described as followed :
When I launch the test from Intellij, I have this Exception on the "Given" method: java.lang.IllegalStateException: Could resolve the return type of the lambda at BusinessEventSteps.kt:19
When using "mvn clean install" from a command line, the test runs fine.
My environment:
MacOS
Coretto 11.0.11
Intellij 2021.1.1
Kotlin 1.4.10
cucumber 6.10.4
Found a workaround.
It seems that the issue has something to do with the native Intellij compiler. Editing the Run/Debug Configurations and replacing the default "Build" step by a maven goal, everything works fine.
Hope this will help others !

build and run Espresso tests having only application apk

Is it possible to build espresso tests having only application apk, witout sources?
connectedAndroidTestMinSdkVersion_14_Debug gradle task is willing to rebuild application. I have seen earlier a guide how to setup test build environment seperated from application build, using gradle, but unfortunately cant find it again.
By the way, wat is the base solution to run espresso tests in continious integeration if application under test is built by Ant scripts?

Can I use Spock and Geb without Grails or Gradle or anything else?

I'm a QA and I want to use Spock + Geb for my testing. As I understand I have to setup grails (or gradle, or something like that) to use Spock + Geb. Or Grails is not required? In this case what is the minimal set of programs that I need to install to successfully test any application? Where I need to write test and how to run it?
Sorry for such stupid questions, but all this stuff is new for me and I don't really understand how it works.
The Grails web framework isn't required at all, unless the web app you are testing is written in Grails.
The Gradle build tool isn't necessarily required, but then you don't want to manually download Spock and Geb, manually compile the tests, manually run the tests, or manually set up an IDE. A build tool can automate all of this, and if you aren't using one already, Gradle is the easiest choice.
The Geb Manual explains how to set up a Gradle build for Spock+Geb and links to a fully working example project. Cloning this project (or downloading the zip) will get you started quickly. You don't even have to install Gradle, but can just run it via the gradlew (*nix) or gradlew.bat (Windows) script (for example gradlew test).

continuous testing with gradle

Is there a plugin or some nice way to make gradle compile and test my application in the background?
I know there are some plugins for intellij and eclipse(infinitest amongst others), but I am looking for a general gradle solution regardless of the IDE.
It would be nice to start a testing-deamon and make it use growl or some other notification tool to let me know that the code is not compiling or the tests are failing.
Continuous compilation/testing/etc. are features planned for future versions of Gradle. They will be based on the existing Gradle Daemon.
Update:
Gradle introduced the continuous build feature in version 2.5. The feature is still incubating, but we can already use it in our daily development. The continuous build feature means Gradle will not shut down after a task is finished, but keeps running and looks for changes to files to re-run tasks automatically. It applies perfectly for a scenario where we want to re-run the test task while we write our code. With the continuous build feature we start Gradle once with the test task and Gradle will automatically recompile source files and run tests if a source file changes.
To use the continuous build feature we must use the command line option --continuous or the shorter version -t. With this option Gradle will start up in continuous mode. To stop Gradle we must use the Ctrl+D key combination.
http://mrhaki.blogspot.com.au/2015/08/gradle-goodness-using-continuous-build.html

How to add task to run parallel selenium tests in build.gradle

In our project we are using gradle to nuke the DB and also using gradle to run the selenium test cases in different suites. I am trying to run selenium test casses parallely. How to add task for that.