junit

How to generate javadoc for unit tests in netbeans

I'm using Netbeans (currently 6.7) and I really like how I can generate javadoc from my source code. However my tests also have documentation (valuable documentation!). Is there anyway I can generate javadocs (ideally for both at the same time). Thanks! ...

Intellij idea tests compilation takes too long (compared with Eclipse)

When I "junit" some class, compilation in Idea takes about 4-5 sec. In Eclipse it takes milliseconds. What should I do to speed up Intellij Idea compilation for tests? ...

Where can I find the value of JUNIT_CONTAINER in Eclipse?

I need to find out, in which path this following path is resolved: <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> It's no classpath variabl to be found unter Window->Preferences, Java->Build Path->Classpath Variables. Where can I found the value von JUNIT_CONTAINER/4? Thanks ...

MouseEvent weirdness

I'm trying to create a MouseEvent with certain modifiers for UnitTesting. I'm using J2SE and the following code fails to pass: public void testMouseEventProblem() { MouseEvent event = new MouseEvent(new JPanel(), 1, System.currentTimeMillis(), InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK, 1,1, 0, false); assertEquals(I...

Eclipse: bind some key for all unit tests

Hi! I'm practice TDD and run my tests very often. Eclipse has nice command to run last launched configuration. But when I in some unit test, Eclipse run only test for current unit test. I want run all my unit tests instead. Yes, i can use mouse to run command that run all junit test, but, repeat. I'm run tests very often. ...

JUnit expected tag not working as expected.

I have the following test case in eclipse, using JUnit 4 which is refusing to pass. What could be wrong? @Test(expected = IllegalArgumentException.class) public void testIAE() { throw new IllegalArgumentException(); } This exact testcase came about when trying to test my own code with the expected tag didn't work. I wanted to see ...

compile errors

I am trying to get some code form a course to work on my current installation: eclipse 3.4.2, a project with jdk1.60_13, JUnit 4_4.3.1 but the JUnit types Theories and @DataPoint cannot be resolved. Also e.g. the replay() and verify() methods are not recognized. What am I doing wrong (apart from using Java)? ...

T2 testing

Hi all, I am doing some experiments with T2 on some old Legacy code; the problem is that the code has the tendency to throw IllegalArgumentExceptions. Does anybody out there have a good example on how to tell T2 to ignore these? Thx ...

DBUnit: How to refresh only on failure ?

I am using DBUnit to test a Spring/Hibernate persistence. I created an abstract test: public abstract class AbstractTestCase extends AbstractTransactionalDataSourceSpringContextTests { @Override protected String[] getConfigLocations() { return new String[] { "classpath:/applicationContext.xml", "classpath:/testDataSource...

Problems running unit tests after upgrading from Netbeans 6.5 to Netbeans 6.7

Hi All, I am experiencing issues with existing projects from Netbeans 6.5 in Netbeans 6.7 when selecting a file under "Test Packages" and performing a right click-->Debug, or right click-->Run. The error reported is: java.lang.NoSuchMethodError: main Exception in thread "main" Java Result: 1 I am using JUnit 4.x I have not changed ...

Ant + JUnit: NoClassDefFoundError

Ok, I'm frustrated! I've hunted around for a good number of hours and am still stumped. Environment: WinXP, Eclipse Galileo 3.5 (straight install - no extra plugins). So, I have a simple JUnit test. It runs fine from it's internal Eclipse JUnit run configuration. This class has no dependencies on anything. To narrow this problem do...

Installed Eclipse PDT, I do not have "Run As -> JUnit"

I installed Eclipse PDT and now I want to run a JUnit test in a Java project. The Java perspective is used, but there are no options displayed in the Run As menu item. The "Run Configurations" item has the "launch new configuration" disabled. The tests are JUnit4 (the project compiles with junit4.jar, but not with junit3.jar). How can...

Maven EAR module and EJB dependencies tests

We are building our EAR & EJB projects with maven. It will build all the EJB projects and then they are used as the dependency for EAR, so they are packed into the EAR file eventually. The problem is that each EJB project has junit tests that check the EJB. For now these tests are not very useful because they try to connect to applicati...

JUnit two variables iterating respective value sets, create test functions

Checking function takes two arguments, I want to have a testcase for each element of the cartesian product of the respective domains, but without manually writing all the test cases like in void check(Integer a, Integer b) { ... } @Test public void test_1_2() { check(1, 2); } ... In python I would go with class Tests(unittest.TestC...

Is it possible to synchronize JUnit test cases with the classes under tests within Eclipe?

I know it is possible to create a TestCase or TestSuite with the wizard within JUnit, but how does one sync the code after the class under the test has been modified, such as method signature modification or newly added methods. I would like my TestCases to be able to sync up (remove or add) those changed methods/parameters/method signat...

JUnit Test Runner that creates tests just before running them

I use JUnit 3.x TestRunner that intantiates all tests at once before running them. Is there a Test Runner available that would create each test (or at least each test suite's tests) just before running them? I can use JUnit 4.x runners but my tests are 3.x tests. ...

How to run external testcase(Class,junit) in java program?

How to run external testcase(Class,junit) in java program? ...

unit testing a java constructor that exits the application

Duplicate: Java: How to test methods that call System.exit()? Hello, I am having a bit of a trouble designing a unit test for a method that exits the application by calling system.exit(). Actually this is the constructor of a class which tests some conditions and decides to exit the application. So it is this particular eventuallity th...

Java: Is assertEquals(String, String) reliable?

I know that == has some issues when comparing two Strings. It seems that String.equals() is a better approach. Well, I'm doing JUnit testing and my inclination is to use assertEquals(str1, str2). Is this a reliable way to assert two Strings contain the same content? I would use assertTrue(str1.equals(str2)), but then you don't get th...

@parameters in Junit 4

Can I have more than one method with @Parameters in junit test class which is running with Parameterized class ? @RunWith(value = Parameterized.class) public class JunitTest6 { private String str; public JunitTest6(String region, String coverageKind, String majorClass, Integer vehicleAge, BigDecimal factor) { this.str = reg...