dcsimg
JUnit only runs 1 of my @Test annotated tests
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Maxim_Veksler
Posted On:   Saturday, March 15, 2008 08:53 AM

Hello, This is my test: /** package com.ml.common.utils.test; import static org.junit.Assert.*; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import com.ml.common.utils.MLBeanUtils; /** * @author maximv * */ public class TestMLBeanUtils { public class SimpleBean { int number = 5; String string = "Hello World";   More>>

Hello,

This is my test:

			

/**
package com.ml.common.utils.test;

import static org.junit.Assert.*;

import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import com.ml.common.utils.MLBeanUtils;

/**
* @author maximv
*
*/
public class TestMLBeanUtils {

public class SimpleBean {
int number = 5;
String string = "Hello World";

public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
}

SimpleBean bean;

/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
bean = new SimpleBean();
}

/**
* Test method for {@link com.ml.common.utils.MLBeanUtils#beanExplode(java.lang.Object)}.
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws NoSuchMethodException
*/

@Test
public void testBeanExplodeNoClassReturned()
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

Map.Entry , List > me = MLBeanUtils.beanExplode(bean);

assertFalse(me.getKey().contains("class"));
fail("Should fail!");
}

@Test
public void testBeanExplode()
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

//fail("Not yet implemented");
}

}




I'm expecting testBeanExplodeNoClassReturned to assert and not pass the test, yet it works and finished with 0 errors.


If I uncomment the fail() on testBeanExplode then it fails with 1 error (expected).


Why isn't testBeanExplodeNoClassReturned() running ?



Thank you,

Maxim.

   <<Less

Re: JUnit only runs 1 of my @Test annotated tests

Posted By:   Maxim_Veksler  
Posted On:   Saturday, March 15, 2008 09:03 AM

I've found out the reason:


I'm running JUnit tests using MyEclipse 6.0 expension to eclipse 3.3


I seems that once eclipse compiles the test class it won't recompile it for new method additions (it will for code modification inside methods. This seems like a really nasty bug.


The work around is to go the the "Package Explorer" windows and choosing again "Run As" > "JUnit test" (Shit + Alt + X T)


HTH.

About | Sitemap | Contact