I try to run my BDD scripts via gradle getting the following error message after updating IntelliJ to 2016.2
No implementation for net.thucydides.core.webdriver.WebdriverManager was bound.
while locating net.thucydides.core.webdriver.WebdriverManager
The code raising the error is this:
#Before
public void jeffCanBrowseTheWeb() {
givenThat(jeff).can(BrowseTheWeb.with(theBrowser));
}
The binaries to the browser are linked like this:
test {
System.setProperty("webdriver.chrome.driver","D:\\lib\\chromedriver.exe")
/* Pass all system properties: */
systemProperties System.getProperties()}
The compile dependencies for selenium-java are pointing to the version '2.53.1'
The gradle command: clean test aggregate
I cannot figure out what is wrong since I did nothing else but updating the IDE. Maybe someone has a hint?
Thanks in advance,
Martin
I ran into the same problem when I was following the example in the article mentioned in your comment. In my case (without using an IDE) it seemed to be a out-of-date dependency (which was renamed).
Try changing the dependency 'net.serenity-bdd:browse-the-web' to 'net.serenity-bdd:serenity-screenplay-webdriver' in build.gradle.
Related
I'm trying to create a custom source set and mark its contents in Intellij Idea as a Test Sources Root. I tried to use idea plugin and do it according to the gradle official website but it is not clear for me how it works.
First of all the documentation specifies the following configuration setup
idea {
module {
testSources.from(sourceSets["intTest"].java.srcDirs)
}
}
When I try to use it i receive Unresolved reference: testSources. Where is it coming from?
Then I tried to use:
idea {
module {
testSourceDirs = intTest.java.srcDirs
}
}
it works fine as long as I use only Java. After applying Kotlin plugin however, both kotlin and java + resources folder are again treated as Sources Root not Test Sources. To fix that I had to change from:
testSourceDirs = intTest.java.srcDirs
to:
testSourceDirs = intTest.kotlin.srcDirs
and now all folders are Test Source Root again. Since kotlin.srcDirs also includes java.srcDirs it looks like you have to specify all, otherwise it is ignored...
Now the real issue came when I used gradle-avro-plugin. Applying it made my folders marked as Sources Root again. I believe it is because it adds another avro directory, but just to main source set.
Does anyone know how to make it marked as Test Sources having both kotlin and avro plugin applied? Am I doing something wrong here? Beacause this beheviour seems to be buggy in the first place.
Tested with:
IntelliJ IDEA 2022.3.1 (Ultimate Edition)
Gradle 6.8.3 and 7.4.2
Plugin id("com.github.davidmc24.gradle.plugin.avro") version "1.5.0"
Plugin kotlin("jvm") version "1.7.0"
I have a project that builds into an SDK library.
Before building a release I would like to verify that all configured dependencies are available using a gradle task. Somehow current build operations pass, because it manages to resolve a different version of a misconfigured dependency as it gets used by some other library. However, this is not a guaranteed situation and therefor I'd like a task that verifies if all configured dependencies are actually available or not and otherwise, fail.
I started a Task like this:
abstract class CheckDependenciesTask : DefaultTask() {
#TaskAction
fun checkDependencies() {
project.configurations.forEach { config ->
if (config.isCanBeResolved) {
println("Resolving ${config.name}")
config.resolve()
} else {
println("Not resolving ${config.name}")
}
}
}
}
But that really aims to resolve configs, rather than dependencies. Somehow I'm not able to figure out how to check if dependencies are available. When running lintAnalyzeDebug --info it neatly prints that they are missing, so there must be some command that checks this, but then just fails instead of try to resolve it.
Any idea or pointers on how to achieve this would be appreciated. Thank you.
For some reason, I'm really having a hard time getting display names to actually be respected in JUnit 5 with Kotlin.
Here's a test file I created for the purpose of example:
import org.assertj.core.api.Assertions
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
#DisplayName("Example Test")
class ExampleTest {
#Test
#DisplayName("test name")
fun myTest() {
Assertions.assertThat(false).isTrue()
}
}
But instead of these names being used, it's showing the actual class/method name as if they weren't annotated with #DisplayName at all. Here's the output from ./gradlew test:
project.path.ExampleTest > myTest() FAILED
org.opentest4j.AssertionFailedError at ExampleTest.kt:12
25 tests completed, 1 failed
> Task :test FAILED
I keep thinking there must be something wrong with my Gradle configuration, but the setup is pretty simple so I don't know what I could be doing wrong.
Here's my build.gradle.kts:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.3.60"
id("org.jmailen.kotlinter") version "2.1.2"
id("org.jetbrains.kotlin.plugin.serialization") version "1.3.60"
}
version = "0.1"
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.5.2")
testImplementation("org.assertj:assertj-core:3.14.0")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.test {
useJUnitPlatform()
}
Really scratching my head at this point, so any ideas would be appreciated. It's not using the names I give to my dynamic tests either (in conjunction with #TestFactory), which is particularly annoying.
Finally figured this out. It was an IntelliJ configuration issue. (The display names are never displayed in the command line anyway apparently.)
Turns out I had it configured to use the Gradle test runner instead of the IntelliJ one, which doesn't show custom display names. The solution was to go into IntelliJ settings -> Build, Execution, Deployment -> Gradle and under "Run tests using" select "IntelliJ IDEA"
Thanks go to JBNizet for pointing out that display names are supposed to show up in the HTML test report that Gradle generates but not in the command line, which helped me determine that this was an IntelliJ-specific issue.
It's because IntelliJ uses gradle test runner by default and it does not allow custom display name.
The solution is really simple you just need to change the default test runner from "Gradle" to "IntelliJ Idea".
Preferences
Build, Execution, Deployment
Build Tools
Gradle
Run tests using = IntelliJ Idea
How to change default test runner in IntelliJ Idea
Truth is, for me, after I undid the changes suggested on this post and selected the check icon to the right of the green play button, the description of the tests started to show.
I managed to get it working in surefirereports by using the configuration
in
https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html#Surefire_Extensions_and_Reports_Configuration_for_.40DisplayName
it displays output like this
"name" is from #DisplayName
I had done a simple project, trying to understand how ParameterizedTest and ValueSource works.
From the below picture it finds the import path, but it throws an error when I try to run the code:
Also the gradle file:
Here is a link to the entire project.
You need to put junit-jupiter-params in the testCompile source set.
junit-jupiter-params exports types like #ParameterizedTest and #ValueSource that are needed at compile (and run~) time.
See also: Missing org.junit.jupiter.params from JUnit5
Starting with version 5.4.0-M1 JUnit Jupiter provides an aggregator artifact that bundles all available Jupiter-defining artifacts for easy consumption. See https://sormuras.github.io/blog/2018-12-26-junit-jupiter-aggregator.html for details.
I have a simple use case of building an OSGi bundle using Gradle build tool. The build is successful if there are java files present in the build path, but it fails otherwise.
I am using 'osgi' plugin inside the gradle script and trying to build without any java files. The build always fails with following error:
Could not copy MANIFEST.MF to
I am sure there must be some way to do it in Gradle but not able to fine. Any idea what can be done to resolve this depending on your experience.
I ran into this today as well, and #Peter's fix didn't work for me (I hadn't applied the java plugin in the first place...). However, after hours of Googling I did find this thread, which helped me find the problem.
Basically, it seems that the error occurs (as Peter stated) when no class files are found in the jar - my guess is because the plugin then cannot scan the classes for package names on which to base all the Import and Export information.
My solution was to add the following to the manifest specification:
classesDir = theSourceSet.output.classesDir
classpath = theSourceSet.runtimeClasspath
In my actual build code, I loop over all source sets to create jar tasks for them, so then it looks like this:
sourceSets.each { ss ->
assemble.dependsOn task("jar${ss.name.capitalize()}", type: Jar, dependsOn: ss.getCompileTaskName('Java')) {
from ss.output
into 'classes'
manifest = osgiManifest {
classesDir = ss.output.classesDir
classpath = ss.runtimeClasspath
// Other properties, like name and symbolicName, also set based on
// the name of the source set
}
baseName = ss.name
}
}
Running with --stacktrace indicates that the osgi plugin doesn't deal correctly with the case where both the osgi and the java plugins are applied, but no Java code is present. Removing the java plugin should solve the problem.
I had the same issue also when java code was present.
Adding these two lines to the osgiManifest closure fixed the problem:
classesDir = sourceSets.main.output.classesDir
classpath = sourceSets.main.runtimeClasspath
-- erik