Closed xanderdunn closed 9 years ago
Using gradle 2.6 you can use the plugin syntax to apply this plugin (there should be a link in the readme) - at the moment it looks as though you have only applied the scala plugin which supports junit and testng?
@maiflai Thanks for your help!
I'm sure I'm just being dense with my gradle setup, but I'm still not having luck. I think you're referring to the build scripts shown on the gradle plugins page.
With this, it again builds but runs no tests:
repositories {
mavenCentral()
}
apply plugin: 'scala'
dependencies {
compile 'org.scala-lang:scala-library:2.11.7'
testCompile 'org.scalatest:scalatest_2.11:2+'
testRuntime 'org.pegdown:pegdown:1.1.0'
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.maiflai:gradle-scalatest:0.9"
}
}
apply plugin: "com.github.maiflai.scalatest"
Do you have an example of a working build.gradle that's using scalatest?
Ok, this ended up working fine for me:
repositories {
mavenCentral()
}
apply plugin: 'scala'
dependencies {
compile 'org.scala-lang:scala-library:2.11.7'
testCompile 'org.scalatest:scalatest_2.11:2+'
testRuntime 'org.pegdown:pegdown:1.1.0'
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.maiflai:gradle-scalatest:0.9"
}
}
apply plugin: "com.github.maiflai.scalatest"
The key was that after setting this to my build.gradle, I had to not merely run gradle test
, but first I had to gradle clean
.
Ah, yes - gradle caches the results of tasks based on inputs and outputs - if you make changes to the build script it can require a clean to purge existing state.
You shouldn't have to run clean again - tests will re-run automatically if you modify them or the main source that they are based on. Otherwise you will see the task marked as up to date. Sorry for the confusion.
Sorry - I've been travelling away from a keyboard for the past few days.
Just following up on the modifications to your build script - the plugin syntax I was referring to is the simplified variant at the bottom of the plugins page:
plugins {
id "com.github.maiflai.scalatest" version "0.9"
}
should be sufficient for a simple project; this automates the manual configuration of repository, dependency and plugin application.
@maiflai
Thanks, this ended up working for me. It just took me some time to figure out that I had to put this plugins{} at the top of my build.gradle, but after any buildscript{} blocks.
This is the first time I'm attempting to use gradle and scalatest. I have scalatest working with sbt, but I'm attempting to switch over to gradle.
My build.gradle:
I have my test sources in src/test/scala, as shown in the gradle docs.
gradle --version
:When I run
grade test
, I get this:It's successfully compiling the project, but it isn't running any of the tests. I suspect I've simply made an elementary mistake in my build.gradle.