junit

Can't add JUnit to test and androidTest

a 夏天 提交于 2019-12-24 09:59:52
问题 I need JUnit in both test folders. So I added androidTestCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12' But as soon as I add JUnit to the androidTest I cannot run the tests, because of the error thrownin this log. Any ideas on how to fix this problem? EDIT: I removed the gradle-aware build from the run configuration. Now it says that my TestSuite is empty, but there are tests annotated with @Test 回答1: Hava a try with this in your build.gradle file dependencies { androidTestCompile(

maven dependencies dependencyManagement

帅比萌擦擦* 提交于 2019-12-24 09:58:37
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 比如有的依赖的<scope>是写在子项目中的 <dependencies> 下的<dependency> 标签中, 而有的依赖的<scope>是写在父项目中的<dependencyManagement> 中 。 把验证过程给大家说下,大家也可以自己练手。 首先新建三个项目,Parent作为父项目、projectA、projectB作为子项目。 在父项目Parent中依赖项如下: <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> 在子项目projectA、projectB中没有写任何依赖,在projectA 下运行命令 mvn help:effective-pom,会发现A下面有 junit 4.8.1的依赖。 如果我把 父项目Parent 中的依赖修改如下: <dependencyManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit<

Unit test fails only when running from with Ant task

痞子三分冷 提交于 2019-12-24 09:39:08
问题 I run the same tests from both eclipse and from an Ant task. When running from eclipse all tests pass. When I run Ant junit task, one, single test fails with the following strange error: junit.framework.AssertionFailedError at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423) at org.eclipse.ant.internal.launching.remote.InternalAntRunner

Robolectric not handling getApplicationContext() correctly - NPE

拥有回忆 提交于 2019-12-24 09:36:44
问题 I've been running some tests on an android application using Robolectric and it's been working well until now. My application passes the result of getApplicationContext() to a constructor, but Robolectric should be ensuring the value of this is not null as I am using the BuildActivity() method. The error is in some configuration of my test environment, or a bug in Robolectric. The result is a NullPointerException in the constructor of Toast. My environment: com.android.tools.build:gradle:3.0

Mocking Chained calls in Concrete Class Mockito

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 09:36:37
问题 I am using Mockito services to test the Exception that could be thrown in MyFinalClass and be caught in MyAbstractClass as the concrete method makes a call to the getObject method in MyFinalClass. Please see below code. public abstract class MyAbstractClass{ @Autowired private MyFinalClass myFinalClass; //concrete method protected Object myConcreteMethod(String name){ try{ Object b = myFinalClass.getObject(name); return b; } catch(MyException e){ LOGGER.log("ERROR THROWN" + e); } } } public

Empty Ant <junitreport> report for SoapUI testrunner XML results

一笑奈何 提交于 2019-12-24 09:16:32
问题 I am running a SoapUI project using Ant to get a JUnit report. Here is my build.xml: <project basedir="." default="testreport" name="APIAutomation"> <target name="SoapUI"> <exec dir="." executable="C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\testrunner.bat"> <arg line="-r -j -a -f 'C:\Users\F3020722\Desktop\Notification\New folder' -sFirstLoginTest 'C:\Users\F3020722\Desktop\Notification\New folder\APIRegression.xml'"></arg> </exec> </target> <target name="testreport" depends="SoapUI">

Maven surefire plugin does not detect Junit5 tests

元气小坏坏 提交于 2019-12-24 09:09:14
问题 I have already looked at Surefire is not picking up Junit 5 tests and a few related questions however things are rapidly evolving with Junit5 that those suggestions don't seem to work anymore. Maven : 3.3.9 I have the following in my pom.xml <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>23.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.7</version> <scope

Where do I verify the load path for my REST webservice

China☆狼群 提交于 2019-12-24 08:47:51
问题 I have just finished coding webservices. I need to be able to debug the webservice load path. When I sudo restart service tomcat7 , the /var/log/tomcat7/catalina.2014-09-29.log provides us with the package path for the webservice INFO: Scanning for root resource and provider classes in the packages: com.swipex.backend.webservices INFO: Root resource classes found: class com.swipex.backend.webservices.Registration class com.swipex.backend.webservices.Activation When I run the junit test code

How to ensure load time weaving takes place for Eclipselink when using SpringBootTest with other tests running beforethe Spring one

[亡魂溺海] 提交于 2019-12-24 08:36:02
问题 I'm using Spring Rest Docs to generate documentation for my REST services. This involves running unit(strictly integration) tests that run against a live Spring Boot Container that is kicked off by the test. The test class looks like this: @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = MySpringConfiguration.class) @WebAppConfiguration public class ApiDocumentation { private MockMvc mockMvc; @Rule public final JUnitRestDocumentation restDocumentation = new

Selenium RC - disabling browser cookie

痴心易碎 提交于 2019-12-24 08:23:58
问题 Is it possible to disable a browser cookie using selenium, RC specifically? If so, what is the api call or sequence of calls to make this happen. There is a feature being tested where theres a need to verify the behavior when cookies are enabled or disabled. Thanks 回答1: As specified in the comment. If you are using FF, you could specify the profile to be used. The way to do it it so specify the browserStartCommand (3rd argument of the DefaultSelenium constructor) to something similar to: