junit4

Robolectric+Eclipse Can't find resources?

ε祈祈猫儿з 提交于 2019-12-04 02:39:12
I just configured a test project for my Android app to use Robolectric. I followed the Eclipse Quick Start . An exception is raised executing my simple very first test. java.lang.RuntimeException: java.lang.NullPointerException at com.xtremelabs.robolectric.res.ResourceLoader.init(ResourceLoader.java:93) at com.xtremelabs.robolectric.res.ResourceLoader.getStringValue(ResourceLoader.java:271) at com.xtremelabs.robolectric.shadows.ShadowResources.getString(ShadowResources.java:56) at android.content.res.Resources.getString(Resources.java) at org.xxx.mobile.android.teldir.app

How do I pass parameters to a Junit test from Ant?

。_饼干妹妹 提交于 2019-12-04 02:05:21
I'm using Junit under Ant to perform Selenium Test.My test cases need to read files which contain test data(in order to accomplish data driven test). I don't mind embedding the file names in the test cases, but I'd like to have the name of the directory where the data files are stored parameterized in the build.xml file. What's the best way to pass information like that from build.xml down into the test cases? Is it a good idea to use ant property? Is it possible to inject Junit4 parameter from build.xml? The junit task accepts nested sysproperty elements. <junit fork="no"> <sysproperty key=

Testing EditText errors with Espresso on Android

纵然是瞬间 提交于 2019-12-04 02:01:24
I want to test if an EditText field has an error (set with editText.setError("Cannot be blank!")). I've created an Espresso test case with the new AndroidStudio 2.2 feature, to record Espresso tests. So the code is pretty much auto-generated. But for now it only checks if the editText is displayed. @RunWith(AndroidJUnit4.class) public class CreateNoteActivityTitleCannotBeBlank { @Rule public ActivityTestRule<CreateNoteActivity> mActivityTestRule = new ActivityTestRule<>(CreateNoteActivity.class); @Test public void createNoteActivityTitleCannotBeBlank() { ViewInteraction floatingActionButton =

Do not wait for page to load

我与影子孤独终老i 提交于 2019-12-04 01:40:25
问题 My problem is that the site from which I have to fetch data is taking too much time in loading which increases the execution time of my testcase. I don't want to wait for whole site to load. What can I do? I have used timeout of 30 sec but it doesn't throw exception even if time is exceeded. May be all the javascripts are called in the onload event of webpage. It is very important to decrease the execution time of the test case, I have just started working with selenium and don't have

Autowiring not working in Spring 3.1.2, JUnit 4.10.0

坚强是说给别人听的谎言 提交于 2019-12-04 00:55:44
问题 Using Spring 3.1.2, JUnit 4.10.0, and pretty new to both versions. I'm having the problem that I can't get the annotation-based autowiring to work. Below are two samples, the one not using annotations, which is working fine. And the second one using annotation, which doesn't work, and I don't find the reason. I followed the samples of spring-mvc-test pretty much. Working : package com.company.web.api; // imports public class ApiTests { @Test public void testApiGetUserById() throws Exception {

Why should Test methods in Junit be defined public?

前提是你 提交于 2019-12-04 00:36:07
问题 I was going through the documentation for junit tests but am unable to understand the need for defining tests as public.Could anyone share some info on this? I read on https://github.com/junit-team/junit/blob/master/src/main/java/org/junit/Test.java But am still not clear with the reason. With is I meant why can't I write something as @Test private void testAdd(){ } 回答1: The JUnit framework calls your test methods from outside your test class. If your test methods are private, it won't be

Spring Test DBunit Warning

前提是你 提交于 2019-12-04 00:30:32
I am using spring-test-dbunit and I get a warning in my Unit tests with this message: Code: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/context.xml"}) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class }) public class TestDB { @Autowired private ICourseService courseService; @Test @DatabaseSetup("sampleData.xml") public void testFind() throws Exception { List<Course> courseList = this.courseService.getAllCourses();

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

时光总嘲笑我的痴心妄想 提交于 2019-12-03 23:56:17
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:693) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)

Auto download pdf files in Firefox

半城伤御伤魂 提交于 2019-12-03 21:48:40
I'm doing tests with Selenium and JUnit. I'm trying to export a report (pdf and xls). With Selenium, I click the download link, and do a verifcar to assert that the file is in the correct folder. I was able to test with the xls, but Firefox always asks what I want to do with the PDF. The configuration of Firefox, Selenium is this: String downloadPath = new File("src/test/resources/firefox_download").getAbsolutePath(); firefoxProfile.setPreference("browser.download.dir", downloadPath); firefoxProfile.setPreference("browser.download.lastDir", downloadPath); firefoxProfile.setPreference("browser

Struts 2 JUnit Plugin v2.2.3: Test Class Extending StrutsTestCase; 'request' is null

守給你的承諾、 提交于 2019-12-03 21:39:26
I am attempting to use the Struts2 JUnit Plugin (v2.2.3 w/ Struts2 v2.2.3) and have run into several issues. I attempted to use the Struts2 JUnit Plugin Tutorial as a guide. The first change I needed to make (not in the guide) is to annotate my test class with: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath*:applicationContext-test.xml"}) because I was getting the error when trying to run my unit test: SEVERE: [56:51.239] ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ********** Looks like the Spring listener was not configured for your web