Running unit tests on a Java sub-project in Android Studio - junit

I am not able to run any JUnit test on a Gradle sub-project in Android Studio. This project does not rely on Android in any way, it uses only the Java Gradle plugin.
The Android Gradle project has the following folder structure:
settings.gradle
app/build.gradle
backend/build.gradle
settings.gradle lists the two sub-projects:
include ':app', ':backend'
The app folder contains an Android project. It's build.gradle file looks like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.6'
}
}
apply plugin: 'android'
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
}
dependencies {
compile project(':backend')
}
The backend folder contains a normal Java Gradle project, which app depends on. It's build.gradle file looks like this:
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.11'
}
The backend project has several unit tests located in src/test/java/...
When I try to execute any of them, I get an error stating the Android Studio cannot find the test class:
Class not found: "com.test.DummyTest"
Process finished with exit code 1
Executing gradle test works as expected. Is there any configuration I have missed, or is it plain impossible to get the unit tests to work in Android Studio?

Support for running JUnit test in Java modules was added in version 0.3.6 of Android Studio:
https://code.google.com/p/android/issues/detail?id=60916

1- If you are using Android Studio,It sounds like Gradle Unit Test Plugin is what you are searching for.
2- As an alternative, you may use The EAP of IntelliJ IDEA 13, which includes all of the Android Studio features except for the redesigned new project wizard and the App Engine cloud endpoints integration, is available now

Related

Passing the ArchiveName to UploadArchives in gradle

Having migrated from Spring Boot 1.5.19 to Spring Boot 2.0.4, we are encountering problems with the build on jenkins. Using gradle 4.2.1. We think the behavioural changes in the spring boot gradle plugin between the versions is causing our issue.
The spring Boot gradle plugin has also been updated from 1.5.19 to 2.0.4
Our target artefact naming convention is :
project-name-<version>-<branch>-RELEASE.jar
The jar file gets generated correctly, having specified the following in the build.gradle file.
bootJar {
baseName = 'project_name'
}
The problem occurs when the uploadArchives task is executed. This task looks for an artefact with the following naming convention.
<path-folder-name>-<version>-<branch>-RELEASE.jar
where is the name of the folder path on the jenkins.
It doesn’t seem to be picking up the baseName config.
The build pipeline runs successfully when we don’t perform the uploadArchives task. Also, prior to the Spring Boot upgrade, this was not an issue.
Is there a way to get uploadArchives task to look for the generated jar file name?
I resolved this eventually by adding a settings.gradle file and defining a a root project name in that
rootProject.name = "project_name"
I think the upgrading of the spring Boot gradle plugin must have changed the way the project was being defined.
The 1.5.* version seemed to be taking the project name from the baseName in the Jar task, but the newer version was using the folder name where the app sits.
That was fun

How do I import Primefaces 6.0 source as maven project in Eclipse?

I followed Building From Source https://github.com/primefaces/primefaces/wiki/Building-From-Source instructions. Building the SNAPSHOT version project from command works well.
However, importing it into eclipse using the Existing Maven Projects wizard gives me a lot of errors in the Problems view. I fixed the lifecycle mappings by setting all to ignore.
I realized the generated source code in the target/generated-sources/maven-jsf-plugin directory but it was not picked up by the m2e plugins as a source folder automatically. So I included it into the eclipse build path manually. But then again, many compile errors show up in the generated code.
Does anybody use eclipse as IDE for primefaces development? How do you setup the eclipse project to develop primefaces?
The eclipse project uses Java Compiler compliance level 1.5 derived from the pom.xml maven-compiler-plugin settings. Setting the Java Compiler compliance level to 1.6 solved the issue for me.

LibGDX RoboVM Package for App Store .ipa crashes after splash screen

I have an libGDX iOS application that works perfectly when testing in Eclipse via Run as iOS Device or Run as Simulator. However, when I use RoboVM Tools -> Package for App Store to get an .IPA file that I install on my iPad, it crashes after the libGDX splash screen.
It isn't a problem with provisionals or certificates since my Run Configurations are exactly the same as the options I used to export.
This problem seems to be pretty common after gradle build, but I have not found a solution yet. Can someone shed some light?
Thanks!!!
I had the problem (run without problems on simulator/device, but crash on Testflight by using ad-hoc generation). I fix it by upgraded libGDX / RoboVM version
Set libGDX in version 1.1.0 and RoboVM to the 0.14 snapshot (maybe not stable, but my game doesn't crash anymore)
I give you my gradle setting :
allprojects
{
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'flappy_gobelin'
gdxVersion = '1.1.0'
roboVMVersion = '0.0.14-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
I used the box2d in my project. And I got the same problem.
I created lib folder in iOS project, then copy the gdx-box2d-1.1.0.jar to that folder, and add it to the build path.
The .ipa file worked.
(But it still didn't work on iOS 8.0)

Jenkins, xcodebuild -> JUnit-Tests with Appium?

i am using Jenkins CI to build my iOS-Project. For this task, I use a sh-script to build the binaries directly from a git-repo by running xcodebuild and thats working pretty well.
Currently I run JUnit-tests with appium from eclipse to test my app, but I would like to integrate them into Jenkins as well. I found some tutorials to integrate JUnit-tests into jenkins by using ant-scripts, but I dont use ant to build my project.
how can I integrate my JUnit-tests into jenkins, without a ant-script? Or should I use a ant-script?
thank you.
I switched now to Gradle Build Automation which is much easier to handle and can be integrated into Jenkins as well by using Jenkins Gradle Plugin. xCode-Projects can automatically be build from Gradle by using Gradle xcode plugin and its easy to integrate JUnit or NGTests into a Gradle Scripts. In java test classes I am able to use selenium driver against appium server who's remote controlling iOS-Simulator.

Enabling Ant Tools in a new Eclipse Galileo installation

I have recently installed Eclipse Galileo with the PHP Developers Tools. I plan to install the Flash Builder 4 Plug-in to do ActionScript development as well.
I want to use Eclipse to both create an ant build script and execute it to compile ActionScript docs from an ActionScript 3 code library.
The problem is that when I try to run a build.xml file (which every site that answers the ant build questions says it should handle automatically) I never see an option to run it as an Ant Build, not can I find any way to associate XML files to Ant in the Preferences or External Tools dialogs.
I;ve seen numerous tutorials on build Ant build files, but never anything about running the actual build script.
Try to install "Eclipse Java EE Developer Tools" component. It's in "Web, XML, and Java EE Development" of "Galileo - http://download.eclipse.org/releases/galileo" repository.