Failed to instantiate spec 'KernelTest' - testing

I only try spock test, and get "Failed to instantiate spec 'KernelTest'", here is my full code
following is my code:
// build.gradle
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.9'
compile gradleApi()
testCompile 'junit:junit:+'
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3'
}
my test is:
// KernelTest.groovy
package ro.gd
class KernelTest extends spock.lang.Specification {
def 'test smth'() {
expect: 1 == 1
}
}
it raise:
ro.gd.KernelTest > initializationError FAILED
org.spockframework.util.InternalSpockError
Caused by: java.lang.ExceptionInInitializerError at KernelTest.groovy:-1
Caused by: groovy.lang.GroovyRuntimeException at KernelTest.groovy:-1

I can get it to work with the latest gradle if I change ro/build.gradle to use a specific version of groovy:
compile 'org.codehaus.groovy:groovy-all:2.3.9'
And then change the dependencies of ro-gd/build.gradle to:
dependencies {
compile gradleApi()
testCompile project(":ro")
testCompile 'org.spockframework:spock-core:1.0-groovy-2.3', {
exclude module: 'groovy-all'
}
}

Related

Data Class with Nullable Parameter in Kotlin 1.5.0 & 1.6.0 Throwing BackendException

Recently updated from Kotlin 1.4.20 to 1.5.30.
I have this class which used to compile no problem
data class Optional<M>(val value: M?)
However, after upgrading, I get the following exception
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: .../Optional.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:55)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:41)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.doGenerateFilesInternal(JvmIrCodegenFactory.kt:191)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:60)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:321)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:113)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:56)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:412)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:112)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:358)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:300)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:119)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:170)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:81)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1658)
I get that it's telling me that Any's toString() method doesn't have a body as I can see that from looking at the source code.
What I don't understand is how to rectify it.
EDIT
Can confirm this still happens when upgrading to kotlin version 1.6.0.
It also happens in this data class:
data class Advertisement(
var id: String,
var image: String,
var navUrl: String?
)
My build.gradle file for this module looks like so:
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.stustirling.redacted-gradle-plugin'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
implementation "com.jakewharton.timber:timber:$timberVersion"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
implementation "org.json:json:$testOrgJsonVersion"
implementation "net.sf.biweekly:biweekly:$biweeklyVersion"
testImplementation "junit:junit:$junitVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "org.mockito:mockito-inline:$mockitoInlineVersion"
testImplementation "org.json:json:$testOrgJsonVersion"
}
redacted {
redactAllDataClasses true
redactClassName true
}
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
My Gradle couldn't find the redacted-gradle-plugin but both of your classes compiles with this minimalistic build.gradle.kts:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
val kotlinVersion = "1.6.0"
kotlin("jvm") version kotlinVersion
}
repositories {
mavenCentral()
}
Also, while looking at the redacted page at https://github.com/StuStirling/redacted-compiler-plugin, it says "Kotlin compiler plugins are not a stable API", so at least do a "./gradlew clean"!

java.lang.NoClassDefFoundError: org/junit/platform/launcher/TestExecutionListener

I am trying to create a test class (JUnit 5) using Intellij Idea but I get the bellow error. When I created the test class it did NOT show the fix button so I am pretty sure the library is in class path.
Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/platform/launcher/TestExecutionListener
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:45)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.TestExecutionListener
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 13 more
My build.gradle looks as below:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
group 'ict221'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.11
mainClassName = 'boardgame.gui.RunGame'
repositories {
mavenCentral()
}
test {
useJUnitPlatform()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}
javafx {
modules = [ 'javafx.controls', 'javafx.fxml' ]
version = "11.0.2"
}
Any help is much appreciate it.
As mentionned by #CrazyCode in comments, with Intellij you need to specify the version of JUnit (because Intellij is bundled with old version of JUnit)
Add this :
dependencies {
...
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.6.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.1")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.6.1")
}
try entering these depencies for junit5 in a gradle project
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.7.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.2")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.2")
Below is an example of a build.gradle for a simple application with JDK 17, Gradle 7.5.1 and JUnit Jupiter 5.9.0, which causes IntelliJ IDEA to correctly run unit tests with JUnit.
Notice that there is no need to add test dependencies as it is done automatically by configuring testing section.
build.gradle
plugins {
id 'application'
}
group = 'your.app'
version = '0.0.1'
sourceCompatibility = '17'
repositories {
mavenCentral()
}
dependencies {
}
testing {
suites {
test {
useJUnitJupiter('5.9.0')
}
}
}
application {
mainClass = 'your.app.App'
}
src/main/test/your/app/AppTest.java
package your.app;
import org.junit.jupiter.api.Test;
class AppTest {
#Test
void testFeature() {
}
}

Spring Integration Http imports not being recognized

The below imports are not being recognized in my code:
org.springframework.integration.http.support.DefaultHttpHeaderMapper
org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler
I want to use the HttpRequestExecutingMessageHandler and DefaultHttpHeaderMapper in my code but its unable to recognize it.
I have the below dependencies in my gradle file
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
jcenter()
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('org.springframework.build.gradle:propdeps-plugin:0.0.7')
classpath 'org.ajoberstar:gradle-git:1.7.0'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-actuator-docs')
compile('org.springframework.boot:spring-boot-starter-integration')
compile('org.springframework.boot:spring-boot-starter-activemq')
compile('org.springframework.boot:spring-boot-starter-batch')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-cache')
compile('javax.cache:cache-api')
compile('org.ehcache:ehcache:3.+')
compile('org.springframework.cloud:spring-cloud-starter-aws')
compile('com.h2database:h2')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-validation')
compile('org.springframework.retry:spring-retry')
compile "org.apache.commons:commons-lang3:3.4"
compile('commons-codec:commons-codec:1.10')
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.+')
compile 'org.apache.httpcomponents:httpclient:4.5.+'
compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.+'
compile 'com.amazonaws:aws-java-sdk-bom:1.11.115'
compile 'com.amazonaws:aws-java-sdk-s3'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
optional('org.springframework.boot:spring-boot-configuration-processor')
optional('org.springframework.boot:spring-boot-devtools')
}
Should i be using any other imports or should the version of any dependency be different? Please advise.
Looks like you are missing this one:
compile('org.springframework.integration:spring-integration-http')
Spring Boot doesn't provide that dependency by default.

VerifyError from com.google.android.gms:play-services:4.4.52 dependency

After including com.google.android.gms:play-services:4.4.52 dependency (for Google+-Login within the Android app) I have a problem running the test cases with Robotium and JUnit on Jenkins. It seems that no matter which test case, the test fails with VerifyError (I've also already observed ClassNotFound- and NoClassDefFoundError's afterwards).
Stacktraces:
VerifyError:
java.lang.VerifyError: org/catrobat/catroid/uitest/content/brick/SetSizeToBrickTest
at java.lang.Class.getDeclaredConstructors(Native Method)
at java.lang.Class.getConstructors(Class.java:508)
at android.test.suitebuilder.TestGrouping$TestCasePredicate.hasValidConstructor(TestGrouping.java:228)
at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:217)
at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:213)
at android.test.suitebuilder.TestGrouping.select(TestGrouping.java:172)
at android.test.suitebuilder.TestGrouping.selectTestClasses(TestGrouping.java:162)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:358)
at pl.polidea.instrumentation.PolideaInstrumentationTestRunner.onCreate(PolideaInstrumentationTestRunner.java:432)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
ClassNotFoundException:
java.lang.ClassNotFoundException: org.catrobat.catroid.test.utils.SimulatedSensorManager
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
at android.test.SimpleCache.get(SimpleCache.java:31)
at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:358)
at pl.polidea.instrumentation.PolideaInstrumentationTestRunner.onCreate(PolideaInstrumentationTestRunner.java:432)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org/catrobat/catroid/test/utils/SimulatedSensorManager
... 27 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.catrobat.catroid.test.utils.SimulatedSensorManager" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/org.catrobat.catroid.test-1.apk", zip file "/data/app/org.catrobat.catroid-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.catrobat.catroid.test-1, /data/app-lib/org.catrobat.catroid-1, /vendor/lib, /system/lib]]
The (relevant part of) build.gradle file:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
// classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
repositories {
mavenCentral()
}
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply from: 'gradle/adb_tasks.gradle'
apply from: 'gradle/code_quality_tasks.gradle'
apply from: 'gradle/intellij_config_tasks.gradle'
//apply plugin: 'com.google.gms.google-services'
check.dependsOn 'checkstyle'
check.dependsOn 'pmd'
android {
compileSdkVersion 23
buildToolsVersion '23.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
applicationId 'org.catrobat.catroid'
testApplicationId "org.catrobat.catroid.test"
testInstrumentationRunner 'pl.polidea.instrumentation.PolideaInstrumentationTestRunner'
versionCode 24
println "VersionCode is " + versionCode
versionName "0.9.17"
println "VersionName is " + versionName
buildConfigField "String", "GIT_DESCRIBE", "\"${versionName}\""
buildConfigField "String", "GIT_CURRENT_BRANCH", "\"${getCurrentGitBranch()}\""
}
defaultConfig {
multiDexEnabled = true
}
}
ext {
projectVersion = "0.9"
}
configurations {
compile.exclude group: 'xpp3' //compile problem with xstream
natives
}
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.guava:guava:18.0'
compile ('com.squareup.okhttp:okhttp:2.3.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms'
}
compile ( 'com.google.code.gson:gson:2.3.1') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms'
}
compile 'com.github.johnpersano:supertoasts:1.3.4#aar'
compile 'com.thoughtworks.xstream:xstream:1.4.7'
def gdxVersion = '1.6.2'
compile 'com.badlogicgames.gdx:gdx:' + gdxVersion
compile 'com.badlogicgames.gdx:gdx-backend-android:' + gdxVersion
natives 'com.badlogicgames.gdx:gdx-platform:' + gdxVersion + ':natives-x86'
natives 'com.badlogicgames.gdx:gdx-platform:' + gdxVersion + ':natives-armeabi'
natives 'com.badlogicgames.gdx:gdx-platform:' + gdxVersion + ':natives-armeabi-v7a'
compile 'com.facebook.android:facebook-android-sdk:4.4.0'
compile 'com.google.android.gms:play-services:4.4.52'
//compile 'com.google.android.gms:play-services-plus:7.8.0'
//compile 'com.google.android.gms:play-services:7.8.0'
compile fileTree(include: '*.jar', dir: 'catroid/libs')
compile fileTree(include: '*.jar', dir: 'catroid/libs-natives')
androidTestCompile fileTree(include: '*.jar', dir: 'catroidTest/libs')
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.2.1'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
pmd 'net.sourceforge.pmd:pmd:5.1.1'
checkstyle 'com.puppycrawl.tools:checkstyle:6.7'
}
task copyAndroidNatives() {
file("catroid/jniLibs/armeabi/").mkdirs();
file("catroid/jniLibs/armeabi-v7a/").mkdirs();
file("catroid/jniLibs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("catroid/jniLibs/armeabi-v7a")
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("catroid/jniLibs/armeabi")
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("catroid/jniLibs/x86")
if(outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
if (project.hasProperty('jenkins')) {
project.android.dexOptions.preDexLibraries = false
project.android.dexOptions.javaMaxHeapSize = "2048M"
}
On my device (Nexus 4 with Lollipop) The app itself is running without any problems when signing in to Google+. Also within Android Studio tests seem to run without these exceptions. I've already tried to disable bytecode verification during testing like:
tasks.withType(Test) {
scanForTestClasses = false
include "**/*Test.class"
test {
// set JVM arguments for the test JVM(s)
jvmArgs '-XX:-UseSplitVerifier'
}
}
but I still had the same errors.
Also to note, I haven't compiled the current version 'com.google.android.gms:play-services:7.8.0' or 'com.google.android.gms:play-services-plus:7.8.0', respectively, because we first need to replace ActionBarSherlock with AppCompat (otherwise it won't compile). I'm also not sure whether I need to apply the 'com.google.gms.google-services' plugin (seems to work without the plugin) - I haven't included it yet because it changes the task structure, where our automated Jenkins test system depends on.
Even after hours of searching I don't really understand why this happens.

How to configure selenium tests with gradle?

i want to run selenium tests with gradle on jboss, and i was able to make the required configuration and i want to share it with the community.
I made a complete example here on my Github acccount.
My dependencies, using only mavenCentral repo are:
dependencies {
compile group: 'org.sikuli', name: 'sikuli-api', version: '1.0.+'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
compile group: 'commons-io', name: 'commons-io', version: '1.3.+'
compile group: 'junit', name: 'junit', version: '4.+'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
compile group: 'net.sf.opencsv', name: 'opencsv', version: '2.+'
}
I would run JBoss7 as a service (on windows) instead of trying to execute it directly from Gradle. I wrote a script to register a service if you want to use it. Then, you just make a gradle task to execute the script with the "start" argument to start the service.
Solution is as follows:
gradle.build:
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'findbugs'
//apply from:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle'
apply from: 'emma.gradle'
buildDir = 'build'
sourceCompatibility = 1.7
version = ''
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
}
}
repositories {
mavenCentral()
mavenRepo url: 'http://repository.primefaces.org'
mavenRepo url: 'http://repository.jboss.org/nexus/content/groups/public'
mavenRepo url: 'http://repository.jboss.org/maven2'
mavenRepo url: 'http://maven.springframework.org/release'
mavenRepo url: 'http://repo1.maven.org/maven2'
mavenRepo url: 'http://git.solutionstream.com/nexus/content/repositories/thirdparty'
}
configurations {
compileOnly
weldEmbeddedTestRuntime { extendsFrom testRuntime }
jbossasRemoteTestRuntime { extendsFrom testRuntime, compileOnly }
}
sourceSets {
main {
compileClasspath = configurations.compile + configurations.compileOnly
}
test {
compileClasspath = compileClasspath + configurations.compileOnly
}
selenium {
compileClasspath = compileClasspath + configurations.compileOnly
}
}
dependencies {
//JSF
compile group: 'com.sun.faces', name: 'jsf-api', version: '2.1.22'
compile group: 'com.sun.faces', name: 'jsf-impl', version: '2.1.22'
compile 'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final'
compile 'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final'
//Servlet
compile group: 'javax.servlet', name: 'jstl', version: '1.2'
providedCompile group: 'org.jboss.spec', name: 'jboss-javaee-6.0', version: '1.0.0.Final'
compile 'taglibs:standard:1.1.2'
compile group: 'org.springframework', name: 'spring-web', version: '3.2.2.RELEASE'
//Omnifaces
compile 'org.omnifaces:omnifaces:1.5'
//Prime Faces
compile group: 'org.primefaces', name: 'primefaces', version: '4.0-SNAPSHOT'
compile 'org.primefaces.themes:bootstrap:1.0.10'
// DB
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.3.1.RELEASE'
compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.2.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.9'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-SP4'
compile 'cglib:cglib-nodep:2.2.2'
//Hibernate / JPA
compile 'org.hibernate:hibernate-core:4.1.0.Final'
compile 'org.hibernate:hibernate-entitymanager:4.1.0.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
//JSR-303
compile 'org.hibernate:hibernate-validator:4.3.1.Final'
// Spring Security
compile 'org.springframework.security:spring-security-core:3.1.4.RELEASE'
compile 'org.springframework.security:spring-security-web:3.1.4.RELEASE'
compile 'org.springframework.security:spring-security-config:3.1.4.RELEASE'
//Utility
compile 'com.google.guava:guava:14.0.1'
compile 'commons-lang:commons-lang:2.6'
compile 'org.apache.commons:commons-email:1.3.1'
compile 'com.typesafe:config:1.0.0'
compile 'joda-time:joda-time:2.2'
compile 'org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.3'
compile 'org.slf4j:slf4j-api:1.7.2'
compile 'org.slf4j:jcl-over-slf4j:1.7.2'
compile 'org.slf4j:slf4j-log4j12:1.7.2'
//Mustache Templates
compile 'com.github.jknack:handlebars:1.0.0'
//Projects
//compile project(":ExtraValidators")
////TESTING DEPENDENCIES
testCompile 'com.googlecode.jmockit:jmockit:1.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'com.h2database:h2:1.3.172'
//Spring Testing
testCompile 'org.springframework:spring-test:3.2.3.RELEASE'
/* Selenium */
seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.33.0'
seleniumCompile 'junit:junit:4.11'
seleniumCompile 'org.slf4j:slf4j-api:1.7.2'
seleniumCompile 'org.slf4j:slf4j-log4j12:1.7.2'
seleniumCompile 'org.slf4j:jcl-over-slf4j:1.7.2'
/* Remote Jboss */
testCompile group: 'org.jboss.arquillian', name: 'arquillian-junit', version: '1.0.0-SNAPSHOT'
jbossasRemoteTestRuntime group: 'org.jboss.arquillian.container', name: 'arquillian-jbossas-remote-6', version: '1.0.0-SNAPSHOT'
jbossasRemoteTestRuntime group: 'org.jboss.jbossas', name: 'jboss-as-server', classifier: 'client', version: '6.1.0.Final', transitive: false
jbossasRemoteTestRuntime group: 'org.jboss.jbossas', name: 'jboss-as-profileservice', classifier: 'client', version: '6.1.0.Final'
}
task wrapper(type: Wrapper){
gradleVersion = '1.6'
}
eclipse {
classpath {
downloadSources=true
plusConfigurations += configurations.seleniumCompile
}
}
task selenium(type: Test) {
testClassesDir = sourceSets.selenium.output.classesDir
classpath = sourceSets.selenium.runtimeClasspath + files('src/selenium/resources-jbossas') + configurations.jbossasRemoteTestRuntime
}
you need to start jboss server manually then use the command gradlew clean selenium
copy this list to gradle.build for Mobile testing with appium, testng and selenium
// https://mvnrepository.com/artifact/cglib/cglib-nodep
compile 'cglib:cglib-nodep:3.2.6'
// https://mvnrepository.com/artifact/commons-codec/commons-codec
compile 'commons-codec:commons-codec:1.10'
// https://mvnrepository.com/artifact/org.apache.commons/commons-exec
compile 'org.apache.commons:commons-exec:1.3'
// https://mvnrepository.com/artifact/commons-io/commons-io
compile 'commons-io:commons-io:2.6'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
compile 'org.apache.commons:commons-lang3:3.7'
// https://mvnrepository.com/artifact/commons-logging/commons-logging
compile 'commons-logging:commons-logging:1.2'
// https://mvnrepository.com/artifact/net.sourceforge.cssparser/cssparser
compile 'net.sourceforge.cssparser:cssparser:0.9.24'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compile 'com.google.code.gson:gson:2.8.2'
// https://mvnrepository.com/artifact/com.google.guava/guava
compile 'com.google.guava:guava:23.0'
// https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all
compile 'org.hamcrest:hamcrest-all:1.3'
// https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit
compile 'net.sourceforge.htmlunit:htmlunit:2.29'
// https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit-core-js
compile 'net.sourceforge.htmlunit:htmlunit-core-js:2.28'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/htmlunit-driver
compile 'org.seleniumhq.selenium:htmlunit-driver:2.29.2'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
compile 'org.apache.httpcomponents:httpclient:4.5.4'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
compile 'org.apache.httpcomponents:httpcore:4.4.7'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime
compile 'org.apache.httpcomponents:httpmime:4.5.4'
// https://mvnrepository.com/artifact/io.appium/java-client
compile 'io.appium:java-client:5.0.3'
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
compile 'javax.servlet:javax.servlet-api:3.1.0'
// https://mvnrepository.com/artifact/com.beust/jcommander
compile 'com.beust:jcommander:1.72'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-client
compile 'org.eclipse.jetty:jetty-client:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-http
compile 'org.eclipse.jetty:jetty-http:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-io
compile 'org.eclipse.jetty:jetty-io:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-util
compile 'org.eclipse.jetty:jetty-util:9.4.8.v20171121'
// https://mvnrepository.com/artifact/net.java.dev.jna/jna
compile 'net.java.dev.jna:jna:4.1.0'
// https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform
compile 'net.java.dev.jna:jna-platform:4.1.0'
// https://mvnrepository.com/artifact/junit/junit
compile 'junit:junit:4.12'
// https://mvnrepository.com/artifact/net.sourceforge.htmlunit/neko-htmlunit
compile 'net.sourceforge.htmlunit:neko-htmlunit:2.28'
// https://mvnrepository.com/artifact/com.codeborne/phantomjsdriver
compile 'com.codeborne:phantomjsdriver:1.4.0'
// https://mvnrepository.com/artifact/org.w3c.css/sac
compile 'org.w3c.css:sac:1.3'
// https://mvnrepository.com/artifact/xalan/serializer
compile 'xalan:serializer:2.7.2'
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-api
compile 'org.eclipse.jetty.websocket:websocket-api:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-client
compile 'org.eclipse.jetty.websocket:websocket-client:9.4.8.v20171121'
// https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-common
compile 'org.eclipse.jetty.websocket:websocket-common:9.4.8.v20171121'
// https://mvnrepository.com/artifact/xalan/xalan
compile 'xalan:xalan:2.7.2'
// https://mvnrepository.com/artifact/xerces/xercesImpl
compile 'xerces:xercesImpl:2.11.0'
// https://mvnrepository.com/artifact/xml-apis/xml-apis
compile 'xml-apis:xml-apis:2.0.2'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
compile 'org.seleniumhq.selenium:selenium-java:3.10.0'
// https://mvnrepository.com/artifact/commons-validator/commons-validator
compile 'commons-validator:commons-validator:1.6'
// https://mvnrepository.com/artifact/org.testng/testng
compile 'org.testng:testng:6.11'
// https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'