junit

Ant Build faling with correct class path and database properties.

Buildfile: C:\MyJava\workspace\springapp\build.xml build: buildtests: dropTables: [echo] DROP TABLES USING: org.hsqldb.jdbcDriver jdbc:hsqldb:hsql//localhost [sql] Executing commands [sql] 1 of 1 SQL statements executed successfully createTables: [echo] CREATE TABLES USING: org.hsqldb.jdbcDriver jdbc:hsqldb:hsql//lo...

Sample project for learning JUnit and proper software engineering

I'm having a hard time making the connection between testing and code. I could ask numerous questions here about things like directory structure and naming of test classes and JUnit 3 vs 4 and so on, but I'd rather find a sample project that does it right and learn by reading it. I'd like something not too complex so that I can understa...

AbstractTransactionalJUnit4SpringContextTests: can't get the dao to find inserted data

I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal is really simple: insert some data into the database using the simpleJdbcTemplate, read it back out using a DAO, and roll everything back. JPA->Hibernate is the persistence layer. For my tests, I've created a version of t...

Junit - Adding cookies to UrlResource ( or alternative )

Hi We are using JUnit+Selenium for functional testing of a web site in our project. In several tests we need to download files from the website and compare it with a local resource. We are using UrlResource to do this. UrlResource actualResource = new UrlResource(URL); compareUtil.isResourcesEquals(expectedResource, actualResouce); ...

Junit test with Osgi doesn't start the Jpa component

We're using OSGI and want to write a JUnit Systemtest. We have one component, that interacts with the database using the Java Persistence API (JPA). When we're launching the test, we get an error message, that the database component couldn't be activated. We think, that this error occurs, because jpa doesn't find the persistence.xml. B...

how to understand @Test & @BeforeClass ?

I am beginning with JUnit and do not understand the annotations @Test and @BeforeClass. I have the following code: public class Toto { @BeforeClass public static void setupOnce() { final Thread thread = new Thread() { public void run() { Main.main(new String[]{"-arg1", "arg2"}); } ...

Junit HTML report

Is there a way to (easily) generate a HTML report that contains the tests results ? I am currently using JUnit in addition to Selenium for testing web apps UI. PS: Given the project structure I am not supposed to use ANT :( ...

Separation of JUnit classes into special test package?

I am learning the concepts of Test-Driven Development through reading the Craftsman articles (click Craftsman under By Topic) recommended in an answer to my previous question, "Sample project for learning JUnit and proper software engineering". I love it so far! But now I want to sit down and try it myself. I have a question that I hope...

assert conditions in eclipse

hello I've write a junit test with eclipse , to check the Gui component status ,I use assert : textfield.assert("expected message") i'm searching how to get the error message printed by assert the message saying that the expected text doesn't match th typed text is printed in the eclipse console I like to get this message to generate a...

GWT JUnit console warnings when running tests

So a couple days ago I created some simple unit tests on my GWT app (in eclipse, using JUnit). They ran fine, now when I try them again after adding lots of crap to my app, they still finish fine, they just take longer and pour out a fair bit of console spam, starting with CSS errors: [WARN] CSS error: null [485:24] Error in expression...

How to specify a data set that should be loaded before the test suite run?

Hi all, Is it possible to specify a dataset to be loaded before test suite classes? I am using junit's annotation @SuiteClasses. Tried unitils' annotation @DataSet - looks like it is not possible to use junit's and unitils' annotations in harmony. ...

Android Unit Testing - Resolution & Verification Problems

I just switched the way my Android project is being built and non of my unit tests work any more...I get errors like WARN/dalvikvm(575): VFY: unable to resolve static field X in ..... WARN/dalvikvm(575): VFY: unable to find class referenced in signature These errors only come from my Unit Tests, where classes defined in it can't even...

[Java] How should I unit test Spring, Hibernate and Struts using junit

What is the best practice? How should I implement it so that the database isn't polluted? ...

request scoped beans in spring testing

I would like to make use of request scoped beans in my app. I use JUnit4 for testing. If I try to create one in a test like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:spring/TestScopedBeans-context.xml" }) public class TestScopedBeans { protected final static Logger logger = Logger...

How do I programmatically run all the JUnit tests in my Java application?

From Eclipse I can easily run all the JUnit tests in my application. I would like to be able to run the tests on target systems from the application jar, without Eclipse (or Ant or Maven or any other development tool). I can see how to run a specific test or suite from the command line. I could manually create a suite listing all the ...

EasyMock Class Extension mock isn't mocking methods

I've got this in mycode: import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.reset; import static org.easymock.classextension.EasyMock.verify; ... mockMember = createMock(Member.class); mockMember.incrPlayInPlay(20...

IntelliJ IDEA with Junit 4.7 "!!! JUnit version 3.8 or later expected:"

When I attempt to run the following test in IntelliJ IDEA I get the message: !!! JUnit version 3.8 or later expected: It should be noted that this is an Android project I am working on in IntelliJ IDEA 9. public class GameScoreUtilTest { @Test public void testCalculateResults() throws Exception { final Game game = ...

How to access sprint context in jUnit tests annotated with @RunWith and @ContextConfiguration?

I have following test class @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"/services-test-config.xml"}) public class MySericeTest { @Autowired MyService service; ... } Is it possible to access services-test-config.xml programmatically in one of such methods? Like: ApplicationContext ctx = somehowGet...

How to find Junit tests that are using a given Java method directly or indirectly

Assume there are Java project and Junit project in an Eclipse workspace. And All the unit tests are located in the Junit project and dependent on the application Java project. When making changes to a Java method, I need to find the unit tests that are using the method directly or indirectly, so that I can run the corresponding tests loc...

Trying to write junit test, missing some basics

When I try to use assertNotLesser or assertNotGreater I get compile error .. and eclipse suggest me to create a new method called like this .. http://junit-addons.sourceforge.net/junitx/framework/ComparableAssert.html I found it here I never used these options before but I need to write this test, I can do it jmock as well but I don't k...