(Oops, I dropped the list on the first reply. Re-adding)
Inba,
For more sophisticated rules about what to include, and what to exclude, see
Request.aClass(SomeClass.class).filterWith(myFilter)
Check out the docs on Filter and filterWith to move forward from
there. Good luck,
David
On Tue, Feb 1, 2011 at 3:35 PM, Inbaselvan Gandhi <inb...@gm...> wrote:
> Thanks David, i still getting used to Junit. I just tried and it worked.
> What i couldn't search was for an option to pass a list of methods that i
> would like to execute. Say in this case A and C just not B. I couldn't even
> spot the right docs, if you can help me in this it would be great.
>
> Regards,
> Inba
>
>
> On Tue, Feb 1, 2011 at 2:27 PM, David Saff <da...@sa...> wrote:
>>
>> Because you're running a method in a JUnit-4-style test class, you'll
>> need to use the JUnit 4 test-running mechanism, which is in the
>> org.junit package. Something like:
>>
>> JUnitCore core = new JUnitCore();
>> core.addListener(new TextListener(new RealSystem()));
>> core.run(Request.method(myClass, "methodName"))
>>
>> Share and enjoy,
>>
>> David
>>
>> On Tue, Feb 1, 2011 at 11:31 AM, inba <inb...@gm...> wrote:
>> >
>> > public class TESTCLASS {
>> >
>> > @Before
>> > public void setUp(){
>> > //some setup
>> > }
>> >
>> > @Test
>> > public void testA() {
>> > //some test
>> > }
>> >
>> > @Test
>> > public void testB(){
>> > //some test
>> > }
>> >
>> > @Test
>> > public void testB(){
>> > //some test
>> > }
>> > }
>> >
>> > To run a single method testB in the above class I have code in a main()
>> > as
>> > below
>> >
>> > new TestRunner().start(new
>> > String[]{"-c","TESTCLASS","-m","TESTCLASS.testB"});
>> >
>> >
>> > but this doesn't work and i get an error like this
>> >
>> > Exception in thread "main" java.lang.Exception: Could not create and run
>> > test suite: java.lang.ClassCastException: class TESTCLASS at
>> > junit.textui.TestRunner.start(TestRunner.java:182)
>> >
>> >
>> >
>> > I am trying to execute a method selected in a swing application. At the
>> > end
>> > i would want to get a list of selected methods in the swing gui to be
>> > executed. how do i do this ?
>> >
>> >
>> > --
>> > View this message in context:
>> > http://old.nabble.com/to-run-single-test-in-junit-4-from-a-main-method-tp30814050p30814050.html
>> > Sent from the JUnit - Dev mailing list archive at Nabble.com.
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
>> > Finally, a world-class log management solution at an even better
>> > price-free!
>> > Download using promo code Free_Logger_4_Dev2Dev. Offer expires
>> > February 28th, so secure your free ArcSight Logger TODAY!
>> > http://p.sf.net/sfu/arcsight-sfd2d
>> > _______________________________________________
>> > Junit-devel mailing list
>> > Jun...@li...
>> > https://lists.sourceforge.net/lists/listinfo/junit-devel
>> >
>
>
|