How to run ScalaTests with Intellij in a Mill Project - scala

I have a Scala Project building with Mill.
My ScalaModule is e2e.
Running my tests work on the console, like:
mill e2e.test
However running it as an Intellij ScalaTest it does not pick up my application.conf
The configuration looks fine - it says Use classpath of module: e2e.test
Do I miss something or is not possible yet with Intellij?

Strangely I could fix this by moving resources folder from test to e2e and back again.
So it seems there was some inconsistency in my Intellij project.

Related

SpringBoot 2.5.2 and unit tests

My unit tests work inside Eclipse (Run with Junit Test) when my pom.xml is setup to use SpringBoot 2.3.12.RELEASE. When I try to use 2.5.2 they fail like this:
java.lang.NoSuchMethodError: org.springframework.test.context.TestContext.computeAttribute
They work when you do a Maven build inside or outside Eclipse.
Anybody else having these kind of issues?
Oh boy! It the things you overlook that get you. I had some project dependencies to other projects on my Eclipse project that I had not upgraded yet. As soon as I upgraded everything, all my unit tests started to run. My apologies.
Bob

Inside IDE(IntelliJ), could not find sbt dependies from External Libraries

I am starting a Scala project and I'm using SBT and Intellij 2020.2.3 as my IDE.
I have the following build.sbt file from the project, but I can't seem to get the dependencies in the Idea IDE "External Libraries" section to show up in "libraryDependencies" of SBT after running "sbt update".
The Idea version is that:
The Idea External Libraies are that:
The Sbt libraryDependencies are that:
In my experience , Intellij is very slow to pickup on dependencies and display them.
Bare in mind this is not a reflection on sbt , and asides for the annoyance, you should still be able to sbt compile from the console.
That is the first thing I suggest you test. If you can compile , that means the dependencies were downloaded, are available on the classpath, and its just a matter of getting Intellij to recognize that
You can try one of 2 things, hover over the dependencies in your build.sbt file and you might see a refresh project option , or you can go to module section in project settings and reimport

activator fails to load project after IDE restart (scala, play, intellij idea)

I have a small play application (resultful service) and I am using Intellij Idea. My project compiles fine from the IDE, and I could also use activator to compile and run the application. I quit the IDE (while my application was running inside activator). Now activator or sbt cannot load the build.sbt file and complain:
[MY_APP_FOLDER]/build.sbt:1: error: not found: object play
import play.PlayImport.PlayKeys._
I still can compile from within the IDE.
EDIT: I am thinking if there is some sort of cache for activator that could be corrupted for this application? My other application is loaded into activator with no problem.
I found out that somehow the plugins.sbt was removed from the project folder. After recovering it, the compilation is successful again.

Editing Build.scala in Intellij

I want to migrate our build from maven to SBT, so now I work separatedly on Build.scala file. However I don't benefit from any syntax highlighting (that is quite obvious, I don't have SBT in my classpath). What is the correct way to get SBT to my classpath, adding sbt-launch.jar does not seem to help.
IntelliJ 13 has built-in SBT support; if you're running a lower version, then you can have a look at their sbt plugin.
There's also an sbt plugin on github for generating idea project files. I've had success with running the gen-idea task it provides.
Run sbt gen-idea. It will create a "YOUR_PROJECT_NAME - build" project within your main project (for whatever your YOUR_PROJECT_NAME happens to be). Under the project folder of the build project, I was able to write a Build.scala with the following code:
import sbt._
object Build extends Build {
}
The SBT Build trait is recognized just fine. I'm running IntelliJ 13 build #IU-133-696, Scala plugin 0.30.378.
Eventually what I did is finished to write my build.sbt stub, and opened a project with it. Now everything seem to work.

How to compile tests with SBT without running them

Is there a way to build tests with SBT without running them?
My own use case is to run static analysis on the test code by using a scalac plugin. Another possible use case is to run some or all of the test code using a separate runner than the one built into SBT.
Ideally there would be a solution to this problem that applies to any SBT project. For example, Maven has a test-compile command that can be used just to compile the tests without running them. It would be great if SBT had the same thing.
Less ideal, but still very helpful, would be solutions that involve modifying the project's build files.
Just use the Test / compile command.
Test/compile works for compiling your unit tests.
To compile integration tests you can use IntegrationTest/compile.
Another hint to continuously compile on every file change: ~Test/compile
We have a build.sbt file that is used for multiple projects. Doing sbt test:compile compiled the tests for every single project and took over 30 minutes.
I found out I can compile only the tests for a specific project named xyz by doing:
sbt xyz/test:compile
Using sbt version 1.5.0 and higher test:compile returns deprecation warning.
Use Test / compile.
(docs)