junit4

Bad type on the operand stack in arraylength

耗尽温柔 提交于 2019-12-03 10:25:39
I am trying to test a method using powermock. i haven't written any test cases yet. Just trying to set up the class for Mocking. here is what I have so far: @RunWith(PowerMockRunner.class) @PrepareForTest({ ReadRubric.class }) public class ReadRubricTest { @Before public void setUp() throws Exception { PowerMockito.mock(ReadRubric.class); } @After public void tearDown() throws Exception { } @Test public void invalidFile() throws Exception { } } When I try to run this test I get the following error. java.lang.VerifyError: Bad type on operand stack in arraylength Exception Details: Location: com

Failed to load ApplicationContext for JUnit test of Spring controller

半腔热情 提交于 2019-12-03 10:23:08
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 personControllerTest.java *src main webapp WEBINF app-context.xml @Autowired private PersonService

Does new JUnit 4.8.1 @Category render test suites almost obsolete?

空扰寡人 提交于 2019-12-03 09:17:11
问题 Given question 'How to run all tests belonging to a certain Category?' and the answer would the following approach be better for test organization? define master test suite that contains all tests (e.g. using ClasspathSuite) design sufficient set of JUnit categories (sufficient means that every desirable collection of tests is identifiable by one or more categories) qualify each test with relevant category(ies) define targeted test suites based on master test suite and set of categories

Generating JUnit reports from the command line

跟風遠走 提交于 2019-12-03 08:42:48
问题 I have a test setup for a cloud system that uses a mixture of python for process level control and junit for internal state inspection. Essentially, I bring up several VMs to server as the cloud and then a junit VM which is a member of the cloud but drives tests and checks internal state. Our existing cloud management stuff is driven by python and I would like to maintain this. I have a working setup that will run the JUnit command line via java -ea -cp <classpath> org.junit.runner.JUnitCore

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

旧时模样 提交于 2019-12-03 07:35:54
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({ TestCase1.class, TestCase2.class, ... TestCaseN.class, }) public class IntegrationSuite { //Do Nothing. }

Maven won't run tests

孤者浪人 提交于 2019-12-03 07:26:45
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</artifactId> <version>1.0</version> <properties> <java-version>1.6</java-version> <org.slf4j-version>1.6.6<

Use different Spring test context configuration for different test methods

試著忘記壹切 提交于 2019-12-03 06:12:30
We have a Spring based JUnit test class which is utilizing an inner test context configuration class @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = ServiceTest.Config.class) public class ServiceTest { @Test public void someTest() { ... @Configuration @PropertySource(value = { "classpath:application.properties" }) @ComponentScan({ "..." }) public static class Config { ... New functionalities have been recently introduced to the Service class, for which the concerned tests should be added to ServiceTest. However these would also require a different test context

Unit test Java class that loads native library

一曲冷凌霜 提交于 2019-12-03 06:11:47
问题 I'm running unit tests in Android Studio. I have a Java class that loads a native library with the following code static { System.loadLibrary("mylibrary"); } But when I test this class inside my src/test directory I get java.lang.UnsatisfiedLinkError: no mylibrary in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) How can I make it find the path of native .so

IntelliJ IDEA cannot see Lombok generated code

蹲街弑〆低调 提交于 2019-12-03 05:25:57
问题 I have a Gradle-based project that uses lombok. I have imported this project into IntelliJ IDEA 14.1 (using the Import External Model import method). I can run the JUnit4 unit tests without problem in Gradle, but IntelliJ seems to have a problem seeing the Lombok generated Getters. This is preventing me from running the tests in IDEA. To make sure it wasn't a set up issue, I created a Very simple project and confirmed that the same issue occurs in the simple test project. My versions: Gradle:

Inject mock into Spring MockMvc WebApplicationContext

走远了吗. 提交于 2019-12-03 05:21:41
问题 I'm working to test (via JUnit4 and Spring MockMvc) a REST service adapter using Spring-boot. The adapter simply passes along requests made to it, to another REST service (using a custom RestTemplate ) and appends additional data to the responses. I'd like to run MockMvc tests to perform controller integration tests, but want to override the RestTemplate in the controller with a mock to allow me to predefine the 3rd party REST response and prevent it from being hit during each test. I've been