Java problem: src/main class not compiled in src/test - testing

I have test class(using mockito) in src/test which referring a class in src/main within same project. my reference class in testclass showing java problem with compilation error. i am using gradle build and STS ide.
any suggestion would help me lot. thank you!

Related

Kotlin - Application project template - error main class not found

I am using IntelliJ IDEA 2021.1 (Community Edition) - Build #IC-211.6693.111, built on April 6, 2021.
I created a new kotlin project - project template(JVM): Application, built system: Gradle Kotlin,
project JDK:1.8 version 1.8.0_281.
In the “scr/main/kotlin” folder, I created a kotlin file with a simple code like "fun main(){println(“Hi!”)}.
When I tried to run the file(the build was ok), I got this error: “Could not find or load main class MyAppKt”.
What did I do wrong?
Did you also add your main class to the build.gradle file?
mainClassName = "projectPackage.MyAppKt"
I assume if you are adding the MyAppKt file manually it is not added to the build.grale. But clearly more information about the project would help here. Meanwhile check this post Kotlin - Error: Could not find or load main class _DefaultPackage

"cannot find symbol" error in IntelliJ IDEA Scratch

I am trying to run some code in a Scratch java file, from IntelliJ IDEA, but once I add a class in my project and try to run it, I get the following error:
Error:(1, 45) package com.example does not exist
Error:(11, 9) cannot find symbol
symbol: class MyClass
location: class Scratch
How can I use my project's classes in a Scratch file?
Make sure the Scratch Run configuraiton has the module, which has these classes defined, specified in Use classpath of module drop-down list:
Select the required module from the drop down list in Use classpath of module(as answered by #Andrey)
Now got to Build then select Build Project or Rebuild Project.
These two steps helped me to resolve the issue.Hope it helps you too !

IntelliJ Error: Could not find or load main class cucumber.api.cli.Main [duplicate]

I am new to Intellij IDEA. I have a POM based cucumber-selenium project, where I've created cucumber runner classes for each feature file. While working with Eclipse I was able to execute these runner classes by Right click. However in Intellij IDEA (licensed version), even when cucumber-for-java and junit plugins are enabled in Settings window, I dont get Run option.
Also in Run/Debug configurations window -> Cucumber java -> what should be the main class? My main class has code to launch firefox browser and is in different subpackage.
If i mention "cucumber.cli.Main" in Main class, it gives me error - Could not find or load main class cucumber.cli.Main
Please help.
Thanks,
Provided that cucumber support is enabled you should be able to run the test from .feature file's context menu:
Also in Run/Debug configurations window -> Cucumber java -> what should be the main class?
The class is taken from the jar archive attached when enabling Cucumber support in project. By default, the main class name is cucumber.cli.Main:
Do not forget to specify the package where your step definitions are stored in the Glue filed of the Cucumber Run/Debug Configuration.
I changed the Main class in the configuration to io.cucumber.core.cli.Main worked for me.
I was getting the same issue and following the same idea from the #soumya-jain answer's, the package to get Cli class is different if you are using Cucumber version 4.2.6.
This java doc (https://javadoc.io/doc/io.cucumber/cucumber-core/4.2.6/index.html) says the Cli class is located at "cucumber.api.cli.Main".
So, it depends on which Cucumber dependency you are using in your project.
Cheers!

Intellij IDEA Run configurations for Cucumber runner class

I am new to Intellij IDEA. I have a POM based cucumber-selenium project, where I've created cucumber runner classes for each feature file. While working with Eclipse I was able to execute these runner classes by Right click. However in Intellij IDEA (licensed version), even when cucumber-for-java and junit plugins are enabled in Settings window, I dont get Run option.
Also in Run/Debug configurations window -> Cucumber java -> what should be the main class? My main class has code to launch firefox browser and is in different subpackage.
If i mention "cucumber.cli.Main" in Main class, it gives me error - Could not find or load main class cucumber.cli.Main
Please help.
Thanks,
Provided that cucumber support is enabled you should be able to run the test from .feature file's context menu:
Also in Run/Debug configurations window -> Cucumber java -> what should be the main class?
The class is taken from the jar archive attached when enabling Cucumber support in project. By default, the main class name is cucumber.cli.Main:
Do not forget to specify the package where your step definitions are stored in the Glue filed of the Cucumber Run/Debug Configuration.
I changed the Main class in the configuration to io.cucumber.core.cli.Main worked for me.
I was getting the same issue and following the same idea from the #soumya-jain answer's, the package to get Cli class is different if you are using Cucumber version 4.2.6.
This java doc (https://javadoc.io/doc/io.cucumber/cucumber-core/4.2.6/index.html) says the Cli class is located at "cucumber.api.cli.Main".
So, it depends on which Cucumber dependency you are using in your project.
Cheers!

How to include an Intellij gradle project inside another Intellij gradle project?

I have two java projects as Bukkit/Spigot plugins. Both projects are using gradle, private repositories, and one project should inherit from another.
Projects:
SpigotCore - Contains database management and utility classes. This is the "main" project.
Minigame Framework - Runs minigames. Needs database access and utility class access.
What is the best way to make the Minigame Framework inherit from the SpigotCore project using gradle? I have been unsuccessful in getting Intellij module dependency working. Any and all help is appreciated!
I solved this issue by just compiling the SpigotCore and then including the jar file in my build.gradle file.
Answer used: https://stackoverflow.com/a/20956456/2865125
Now following the answer above, it shaded the SpigotCore classes into the MinigameFramework. This is not what we want since both projects are Bukkit plugins and will be provided at runtime. So I changed "compile" to "provided" and it works great!
The change:
dependencies {
provided files("somePath/spigotcore.jar")
}