I created a test class in Eclipse like this
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:applicationContext.xml" }) @TransactionConfiguration @Transactional public class TeamTest extends AbstractTransactionalJUnit4SpringContextTests { @Test public void testCreate() { assert (true); }}
However, when I click right click on the file I don't see option to run as JUnit!
What is wrong?
I am using Eclipse 3.6
That kind of J icon filled to a "bubble" means that Eclipse doesn't recognize your project as a Java project, and therefore doesn't provide Java options such as Run as JUnit. Try reimporting the project as a Java Project.
Make sure your eclipse environment is using JUnit 4. JUnit 3 doesn't make use of annotations (it uses the old extends TestCase
style)
There are few things to double check:
Window > Preferences > Java > JUnit
Are you seeing junit4
or junit3
imports? If that looks good, make sure the project itself is using JUnit4 instead of JUnit3.
Right Click on project > Properties > Java Build Path > Libraries
Is JUnit4 included there? Is anything JUnit related there? If JUnit3 is in there, click on it and click Remove
. Then click Add Library...
and follow the prompts from there to add JUnit again.
Out of curiosity, are the JUnits run outside of eclipse? Like with a mvn install
or whatever build target you have for Ant that'll run JUnits
Write a simple test case to see if Eclipse works correctly or not. If simple test case can be run, check your testcase, especially import classes.
Or make a try in "Run" -> "Run Configurations",fill the "Test class" as "TeamTest
"(full class name). Then click "Run", see what will happen...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With