junit4

getSupportActionBar() returns null with Robolectric

不问归期 提交于 2019-12-21 12:09:20
问题 The method getSupportActionBar() returns null when i invoke it through a Test Case based in Roboelectric and JUnit. This is my simple test case: package com.mobile.test; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; import org.robolectric.RobolectricTestRunner; import android.app.Activity; import android.content

ClassNotFoundException: junit.framework.TestCase cannot be found by org.eclipse.xtext.junit_2.4.3.v201309030823

回眸只為那壹抹淺笑 提交于 2019-12-21 07:13:15
问题 I'm puzzled by this error: java.lang.NoClassDefFoundError: junit/framework/TestCase at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:792) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188) at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:638) ... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java

Type Android Junit4 not present exception

烂漫一生 提交于 2019-12-21 07:06:56
问题 I have an Android project that I am trying to run Instrumentation tests for using AndroidStudio, but when I try to run the whole class file for the tests, I get the exceptions as stated below : java.lang.TypeNotPresentException: Type android.support.test.runner.AndroidJUnit4 not present Caused by: java.lang.ClassNotFoundException: android.support.test.runner.AndroidJUnit4 Interestingly, I can run individual methods in this Instrument Test class, just not the whole class. My build.gradle file

Type Android Junit4 not present exception

雨燕双飞 提交于 2019-12-21 07:06:39
问题 I have an Android project that I am trying to run Instrumentation tests for using AndroidStudio, but when I try to run the whole class file for the tests, I get the exceptions as stated below : java.lang.TypeNotPresentException: Type android.support.test.runner.AndroidJUnit4 not present Caused by: java.lang.ClassNotFoundException: android.support.test.runner.AndroidJUnit4 Interestingly, I can run individual methods in this Instrument Test class, just not the whole class. My build.gradle file

Java 9 Modules and JUnit 4

对着背影说爱祢 提交于 2019-12-21 04:56:18
问题 Eclipse oxygen; windows 7; JDK 9 final from 9, 21; JUnit 4.12 and an existing application. As starting point the application can be compiled, executed and all JUnit Tests shows green. Now we use eclipse to generate the file module-info.java. The outcome looks like: module ch.commcity.topsort { exports ch.commcity.topsort; requires junit; } But with the error: junit cannot be resolved to module. The question is: How to tell the file that junit does not define any module and it should be run in

Failed to load ApplicationContext for JUnit test of Spring controller

99封情书 提交于 2019-12-21 03:08:07
问题 I want to write a test case to check my controller (getPersons). This is a server side code. I have confusion what should i put inside @ContextConfiguration(locations={"file:src/main/webapp/WEB-INF/app-contest.xml"}) Secondly, I'm getting some errors like this: Failed to load application context. Can not find the path [which I specified in @ContextConfiguration] I have a structure like this: restAPI *src/main/java com.company.controller personController.java *Test com.company.testController

Running a JUnit4 Test Suite in Maven using maven-failsafe-plugin

 ̄綄美尐妖づ 提交于 2019-12-21 01:57:31
问题 I've got a JUnit 4 test suite that contains a number of test classes in the order they need to be run (our Integration tests need to be run in a certain order). If I use the maven-failsafe-plugin without any configuration it will run the test but not in the correct order. However, If I set the plugin to run the test suite no tests are run. Is it possible to run a test suite using the failsafe plugin? if so, where have I gone wrong!! The code is below: @RunWith(Suite.class) @SuiteClasses({

Maven won't run tests

折月煮酒 提交于 2019-12-20 20:03:36
问题 When running mvn test maven won't run all Test Classes. When I explicitly provide a class by adding -Dtest=PropertyTests the tests will be run. Here's my pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>example<

Maven won't run tests

倾然丶 夕夏残阳落幕 提交于 2019-12-20 20:03:14
问题 When running mvn test maven won't run all Test Classes. When I explicitly provide a class by adding -Dtest=PropertyTests the tests will be run. Here's my pom.xml: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>example<

How to handle ordering of @Rule's when they are dependent on each other

不羁岁月 提交于 2019-12-20 16:17:26
问题 I use embedded servers that run inside Junit test cases. Sometimes these servers require a working directory (for example the Apache Directory server). The new @Rule in Junit 4.7 can handle these cases. The TemporaryFolder-Rule can create a temporary directory. A custom ExternalResource-Rule can be created for server. But how do I handle if I want to pass the result from one rule into another: import static org.junit.Assert.assertEquals; import java.io.*; import org.junit.*; import org.junit