junit

Running JUnit Tests in Parallel in IntelliJ IDEA

I have a large suite of tests that takes about half an hour to run and would love to be able to the test classes in parallel. Is there a way to do that with IntelliJ IDEA 9? ...

How to test sql scripts are standard sql in junit tests?

Is there any way to test that SQL scripts contain standard SQL with java/junit tests? Currently we have sql scripts for creating a database etc. in a Postgres db, but when using hsqldb everything fails. That's why I wonder if any java tools exist for testing if sql statements are standard sql. Or would it just be wise to create differe...

What happens if I terminate jUnit tests

Hi, I have a weird question. If I get somehow stuck in my tests, I have to terminate them. But still I need to destroy a background process. Meaning I need some method that is called on the jUnit termination to override. Afterclass method or Finalize aren't it. Is there something? ...

JUnit - testing a web site

I'm very new to JUnit, but I want to set up some tests which does the following.. Tests a range of server to server API calls - verifying the responses are correct - I can do that fine. Open a web page, enter data onto it and verify what happens on submit - This I am struggling with. Is it even possible? I am thinking that I could c...

is it possible to send JUnit test report by email?

Hello, with ant it is possible to run JUnit tests and generate test reports in several formats: text, HTML, XML .. and it is recurrent to send test results by email to the responsible, so my question: is it possible to use the xml file generated by Junit in order to send a summary(Html) of the test execution? or is there another better s...

JUnit assertion methods should be phrased in the positive or the negative?

Should I be writing assertTrue("User logged in", user.isLoggedIn()); or assertTrue("User is not logged in", user.isLoggedIn()); The former provides better reading inside the source files: "I assert that the following is true: User logged in." The error message could be read both ways: java.lang.AssertionError: User logged in "There is ...

How best to unit test Spring's SimpleMappingExceptionResolver

I have extended org.springframework.web.servlet.handler.SimpleMappingExceptionResolver to log and return custom error messages to my Spring MVC application. My question is - how should I go about writing a JUnit test to check that the correct errors get returned when the associated Exceptions get thrown? ...

EasyMock and modifing a mutable method parameter

How does one use EasyMock to modify a mocked method's mutable method parameter? For example, I have class that uses a BlockingQueue. I want to mock the BlockingQueue member for unit testing. My class calls the method queue.drainTo(Collection c). Calling this method removes elements from the queue and adds them to the collection. How...

Test-resources of dependecies not in classpath?

I have a multi module Spring project that I set up using Maven: my-root (pom) - my-logic - my-webapp (depending on my-logic) - my-consoleapp (depending on my-logic) My Test classes inherit from AbstractTransactionalJUnit4SpringContextTests and use @ContextCofiguration for setting up the ApplicationContext. E.g. the test c...

Eclipse junit testing in the same package

Hi, This is a relatively open question. If I have built an application in a project in Eclipse and I then want to test this project, should I create the JUnit code within the same project or create a seperate project. For instance... ShopSystem maybe the name of my main project - should I create a project called say, ShopSystemTest? ...

Can my Eclipse launch profile reference its containing project?

Hi all, I would like to add my Eclipse .launch files for JUnit tests to source control, but it doesn't work because I often checkout the containing project with a different name than it was committed under. The Eclipse .launch files for JUnit tests contain an attribute "org.eclipse.jdt.launching.PROJECT_ATTR", which seems to support no ...

Large amount of unit tests cause freezes with Failed Binder Transaction

Hello, I have about 400 unit tests that I have written for my Android application. If I run the tests package by package, everything works fine and all my tests pass. However, if I try to run them all at once, eventually (about 360 tests in), Android starts spitting out !!! Failed Binder Transaction Errors !!!. After about 10-20 of thes...

I've injected HttpServletRequest into a bean. How do I unit test it ?

I have a bean in which I've injected an HttpServletRequest using the @Autowired annotation. This injection works correctly when the application context is a web application Context. That's not the case for application contexts for JUnit tests with Spring. How can I test this bean ? Maybe I can mock an http request, but then how to inj...

java swing, spring, hibernate session transaction problem.

How do I make sure that there is only 1 sessionfactory/session/transaction when i run a test case? Currently in my test case the DataBase changes (that i make in the test case) are not visible in the application code. Here is the base class of the test. @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "/spring...

Testing Tapestry pages and components with JUnit

I usually try to minimize testing with Selenium and maximize the usage of plain old back-end testing (JUnit, mocking). With Tapestry I am finding it hard to test pages and components in the latter way due to the "magic" that occurs with the callback functions. Have you been able to solve this? Or are you just using Selenium for the whol...

JUnit4 and exception handeling

The following code does not compile, becouse of unreachable catch block. I want write "tues" function and call it in many other unit test functions. Is that possible and how to implement that? private void catchException(boolean condition) { try { assertTrue(condition); } catch (SomeExceptio...

Can JUnit be used as an alternative to browser testing in Spring?

I'm building a Spring web app and up until now all of my testing is using a browser. This involves starting the server, opening a browser window and checking to see if accessing any of the pages causes an error. This is starting to get repetitive and doesn't seem to be the most efficient way to do this. Since the Junit jar file is ...

Could not find class: org.junit.tests.AllTests - OSX

Hi. I'm having a little trouble getting started with JUnit tests. This should be pretty basic. I downloaded junit-4.8.2.jar from JUnit.org and placed it in my home directory. If I try to test my setup in a TCSH terminal with the following command: java -cp ~/junit-4.8.2.jar org.junit.runner.JUnitCore org.junit.tests.AllTests I recei...

Is it possible to change the current time of a thread or jvm instance in java?

I want to test some class methods that contain logic dependent on the current time it is running. I'd like to set the thread/jvm/system time to a specific future date in the JUnit setup and run my tests. Also I would like this to be temporary. Has anyone done this before? I was thinking of something similar to TimeZone.setDefault(timezo...

TestNG test reuse

Need some help thinking in TestNG terms. I have a large third party test suite written in TestNG and I'd like to be able to compose tests from it and run them from Intellij or Maven Is it possible to compose tests together programmatically and still leverage the runners built into these other frameworks. In JUnit you could do this: ...