I had made a Junit Test case using menu options in Eclipse. I was getting the option "Run as JUnit Test". But when I was done with my changes, I noticed that the "Run as JUnit Test" disappeared.
On further analysis I found that my initially my TestClass definition was as below :
public class SampleTest
{
....
}
But I had to change the class definition to follows
public class SampleTest<T>
{
..
}
So what I noticed was adding the generic was creating the behavior. I looked at the following links:
Run As JUnit not appearing in Eclipse - using JUnit4
public class SampleTest<T>
{
..
}
But these links are less related to my issue. So, I need to understand the reason what including Generics has to do with the behavior.
For running a JUnit test class Eclipse needs to
@Test
methods on that instanceHere the problem is in step 1: Eclipse doesn't know which type T
to use in the constructor.
Should it use new SampleTest<Object>()
or new SampleTest<WhatEver>()
?
So it decides that it is not a valid JUnit test class
and doesn't offer the Run as JUnit Test option.