Cucumber kotlin : IllegalStateException when launching test via Intellij - kotlin

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 !

Related

Run Hybris unit test in intellij Idea community edition

i want to run hybris unit test using intellij community edition like how we do it on eclipse.
I don't want to use Hybris intergation plugin as it was failed to defect the unittest that are present in custom directory. when i try to run the test Intellij native build is triggering but not the ant build. and i am resolving the dependencies whenever intellij throws me build fail with those errors.
Can anyone help me to set this up or guide me through what all necessary steps to follow.
I am using latest version of community edition , Junit - 4 & Mockito for writing unit tests.
Thanks in advance.
I was able to Run the tests once i resolved all the errors that was throwing by intellij.
refer the Image here
Once you click on that run button, you get build errors, once you resolve those build errors then automatically that test will run. if it says shorten the command line then
Please refer this article by Intellij, hope this helps.

Intellij error - test framework quit unexpectedly intellij

I have been trying to run junit test but facing this issue constantly. I tried to look for answers on the internet but nothing helped.
]1
If there is an error e.g.
"CommandLineWrapper is ill-suited for launching apps on Java 9+..."
Then, try the following workaround in IntelliJ IDEA:
Run -> Edit configurations -> select the failed running config -> Shorten command line: #argfile (Java 9+) -> OK
For IntelliJ 2019 and above go to :
Settings-> Build,Execution,Deployment -> Build Tools -> Maven -> Running Tests and
Uncheck argLine
I had same issue but it has been resolved by updating the Intellij latest version 2020.3. Now i am able to run the test without any error. Please check below link for latest Intellij versions
https://www.jetbrains.com/idea/download/
I had previously installed zulu and Oracle Java and then switched between the two quite a bit.
I ended up having many JDKs
Here's what helped me.
In intelliJ, go to Run, the Edit Configurations.
In the Run/Debug Configurations window, under Build and run section, select 'Java Bundled'.
To make sure this applies for all tests, click on the edit template icon (the spanner), select JUnit and then in the Build and run section select 'java Bundled'
Make sure all the configurations under JUnit has 'java Bundled' as well
Click Apply and Ok. Try to run the tests now and it should probably work.
For me the problem was that I had some incompatible/old dependencies in my SBT project.
I updated the versions of every 3rd party in the SBT config and running ZIO tests in IntelliJ started working.
For me also, the problem was that I made a change in the dependecies and the dependecy updated was incompatible in the SBT project.

What is needed for Scalatest to work in Intellij with Scala 2.13.0? [duplicate]

I am getting the following error when I try to run tests in IntelliJ (2019.1), Scala IntelliJ plugin v2019.1.8, with Scala 2.13:
Exception in thread "ScalaTest-dispatcher" java.lang.NoSuchMethodError: scala.collection.JavaConverters.seqAsJavaListConverter(Lscala/collection/Seq;)Lscala/collection/convert/Decorators$AsJava;
at org.jetbrains.plugins.scala.testingSupport.scalaTest.treeBuilder.ParallelTreeBuilder.getOrdinalList(ParallelTreeBuilder.java:21)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.treeBuilder.ParallelTreeBuilder$SuiteTree.<init>(ParallelTreeBuilder.java:92)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.treeBuilder.ParallelTreeBuilder.initRun(ParallelTreeBuilder.java:261)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestReporterWithLocation.apply(ScalaTestReporterWithLocation.java:59)
at org.scalatest.DispatchReporter$Propagator.$anonfun$run$10(DispatchReporter.scala:249)
at org.scalatest.DispatchReporter$Propagator.$anonfun$run$10$adapted(DispatchReporter.scala:248)
at scala.collection.immutable.List.foreach(List.scala:312)
at org.scalatest.DispatchReporter$Propagator.run(DispatchReporter.scala:248)
at java.lang.Thread.run(Thread.java:745)
The following are my Gradle dependencies:
dependencies {
implementation 'org.scala-lang:scala-library:2.13.0'
testImplementation 'org.scalatic:scalatic_2.13:3.0.8'
testImplementation 'org.scalatest:scalatest_2.13:3.0.8'
}
When I change the dependencies to Scala 2.12.x, the tests execute correctly in IntelliJ without error. What is going on here?
Update: This has been fixed in plugin version 2019.1.9.
It is possible IntelliJ Scala plugin needs to be updated for 2.13. Meanwhile try workaround by selecting the checkboxes Use sbt and Use UI with sbt under test's Edit configuration.... According to Dmitrii Naumenko:
This is fixed in the
2019.1 EAP #2019.1.8.21
2019.2 Nightly
Will be available soon in 2019.2 EAP and 2019.1 new Release
Regarding Gradle, try configuring to delegate to Gradle Test Runner
Remove exising ScalaTest runners
Go to Build, Execution, Deployment | Build Tools | Gradle | Runner
Select the checkbox Delegate IDE build/run actions to Gradle
Choose Gradle Test Runner

Skip tests in IntelliJ using Gradle

Does anyone know how I can skip JUnit tests in IntelliJ when doing a Gradle build like the following command line version? I have searched extensively for a solution but can't find one. I am in the process of converting an existing project to Gradle and need to support many developers that are not familiar with Gradle, some UX, some front end, and some Java. There are many broken Junit tests in the myriad modules and long-term we will fix them. Short term I need all other developers to use the tools they are familiar with to be able to do their job easily.
./gradlew build -x test
The Gradle-Android Compiler settings allow for command-line options but not non-android projects as shown in the IntelliJ settings dialog shown below.
You should be able to run a standard clean build from intellij if it's a gradle project (aka gradle integration in intellij). Then edit the configuration and add at the script parameters : -x test which will run the clean build (or any other task) without running tests.
I am using Intellij IDEA 2019.3 (Community Edition).
You can skip test using following settings.
You can get to this via Gradle panel located at right top corner.
Select task -> Run Configuration -> Right click -> Edit Run Configuration..
From intellij 2021.2 onwards, type the argument directly in Run text

TestNG tests don't start in IntelliJ 13.1.4

I am unable to run or debug any TestNG tests in IntelliJ 13.1.4 on my Mac. When I try to run the test in debug mode, the IDE is hung starting the test - it never completes.
However, I can work with the same test using an older version of IntelliJ (12.1.7).
So far I've tried changing the JDK, replacing the testng jar in ../IntelliJ13/plugins/testng/lib, reimporting all maven dependencies, rebuilding IntelliJ indices.
Any ideas about how to fix my IntelliJ 13.1.4 environment?
I had similar issue - it turns out that I need to config my JVM options and connection used.
Update:
Sadly no, they are internal resources. But the algorithm should be the same (for your case):
goto Run/Debug Configuration
select TestNG
add your Name for the new configuration
select path to your test suite in Suite
in JDK settings tab, find VM options input your connection configs
run/debug for the Run/Debug Configuration - menu arrows
this worked for me.