junit

Spring - applicationContext.xml cannot be opened because it does not exist

Hello! I have a Spring MVC application and a problem with JUnit tests combined with the file applicationContext.xml. In my JUnit test class I write: final ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); service = (TestServiceImpl) context.getBean("testServiceImpl"); The error I get is that ...

JUnit : my XML file location in @ContextConfiguration isn't found

Hi, This is my JUnit class : @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "WEB-INF/spring-test-config.xml"}) public class TestXXXX extends TestBase { ... When I launch this test class with JUnit runner (from Eclipse), it's failed, because the file spring-test-config.xml is not found. My project arc...

Android - Junit - Tested project uses external Jar

I have some java code (compiles nicely for Android) in a library project (LIB) that I want to use in an another Android project (A). As LIB's code is unlikely to change much, I opted for adding it as a jar to A. It works fine. I have another project that is an Android instrumentation project, testing the first Android project (B). So ...

Unit-testing multithreaded applications

Has anyone got any advice or know of any frameworks for unit-testing of multithreaded applications? ...

Is there a repository of pre-built JUnit tests for common Java Interfaces?

I'm teaching a data structures class this semester and we build gobs of JUnit tests given component interfaces. We then use setUp to plug in a specific concrete implementation. In most cases we are implementing java.util interfaces. Is there a common set of rigorous JUnit tests for common Java components, or some sort of framework tha...

Is there a version of JUnit assertThat which uses the Hamcrest 'describeMismatch' functionality?

In every version of JUnit I have tried (up to 4.8.1), a failing assertThat will display an error message that looks like: expected: [describeTo] got: [String representation of object] In other words, it will display the toString() of the object instead of the mismatch description from the Matcher. If I use the assertThat from org.hamc...

Non-void test methods in JUnit 4

I would like a JUnit 4 test class to implement the same interface as the class its testing. This way, as the interface changes (and it will, we're in early development), the compiler guarantees that corresponding methods are added to the test class. For example: public interface Service { public String getFoo(); public String getB...

spring restTemplate POST parameters from complex object

I'm attempting to test our REST service using restTemplate using the postForObject(...) method. unit test: @Test public void testPostOrder() { String url = BASE_URL + "/orders/"; OrderDto orderDtoInput = new OrderDto(); orderDtoInput.setCustomerId(34); UpdateReportDto updateReport = restTemplate.p...

Junit Test Not Deploying from Ant Script

I have an ant script that I am trying to run my junit test from. It runs all but the junit portion of the ant with no errors. Anyone know why it's not hitting this portion of my script? <?xml version="1.0"?> <property file="build.properties" /> <property name="test.class.name" value="edu.psu.ist.probability.TestProbability" /> <...

Compare two xml files using Junit

Hi, I am writing a JUnit test case which want to test whether a particular file is added with some content or not. In that case, I want to get the instance of the file before modification and another file instance of the same file after modification and want to check whether both are not equal. how to do that in Java Junit ? ...

HowTo Unit Test Client Server Code

Hi, I'm currently writing a Java Client Server Application. So i want to implement two Libraries, one for the Client and one for the Server. The Client Server Communication has a very strict protocol, that I wan't to test with JUnit. As build tool im using Maven and a Husdon Server for continues Integration. Actually I do not have an...

JUnit mocking with Mockito, EasyMock, etc

I'm trying to mock a method of an object inside the class I'm testing. For instance class ClassToTest { public doSomething () { SomeObject a = new SomeObject (); a.doSomethingElse (); } } Is there a way to mock the methods of the variable "a"? I'd like doSomethingElse to do nothing during testing. I'm currentl...

Logging level under maven surefire

Hi, I'm unable to adjust java logging's logging level. I'm using maven surefire (mvn test), and trying to adjust from the default INFO to e.g. FINEST. I have logging.properties file under src/test/resources/logging.properties after compile, i see under target/test-classes, i see a logging.properties file with the intended config: jav...

Show grails test results in Netbeans IDE

Hi, does anybody know a possibility to show the Unit-Test results of a grails project in the "Test Result"-Window of the netbeans IDE? The test results are saved in the project folder as JUnit XML Files. ...

problem with using JPA

I am getting following error while executing a unti test case(JUNIT).I am using it to understand the part of the project.Project is a web based project.Project is using OPENJPA <openjpa-1.2.1-SNAPSHOT-r422266:686069 fatal store error> org.apache.openjpa.persistence.RollbackException: Unable to obtain a TransactionManager using null. ...

Mockito: Injecting Mocks Throughout Control Flow

I'm still learning mockito and right now I'm learning how to inject mocks. I have an object under test with a particular method that depends on other objects. Those objects, in turn, depend on other objects. I want to mock certain things and have those mocks be used everywhere during execution--throughout the control flow of the metho...

NoClassDefFoundError when trying to unit test JSON parsing in Android

I'm working on an Android app where some part of it gets JSON-formatted data from a web service. The basics of the class parsing the JSON data looks like this: public class JsonCourseParser implements CourseParser { public Course parseCourse(String courseData) { Course result; try { JSONObject jsonObject = new JSONObject(cour...

Testing this Activity

I have an Activity I would like to automate testing on. The start up of the Activity is like this: Get data from Intent Bind to service and obtain some objects specific to that Activity's intent data Query these objects and print information to screen I have a basic grasp of testing Activities but given how this Activity depends quit...

Cobertura with Ant Script : xml/html coverage report always show 0% coverage everywhere

I tried to get Cobertura running inside my ant script. All is successfull (source code building, junit tests, cobertura reports (xml / html); but in html reports, the code coverage is always at 0% ... Ant Script : make-instrument <!-- Make instrument for Cobertura engine --> <target name="make-instrument"> <!-- Remove the coverag...

Testing package's classes with JUnit.

Hello. I'm developing an Android application. I have a package to access SQLite3. It isn't a ContentProvider. How can I test the package's classes using JUnit? Thanks. ...