dev@glassfish.java.net

Re: why won't my unit tests run?

From: Justin Lee <Justin.Lee_at_Sun.COM>
Date: Thu, 30 Jul 2009 16:40:26 -0400

Some projects i've worked on look for files named like FooTest.java.
Try renaming your class to that it ends with "Test"

Lloyd Chambers wrote:
> Even more mysterious—
>
> I do have some tests that are being run in common/amx-core-imp.
>
> But when I duplicate one of those tests, changing nothing but the
> classname, the new test compiles and is in target/test-classes, but it
> is ignored, and never run.
>
> I can't find any file that lists tests by name or anything of that sort.
>
> Lloyd
>
> On Jul 30, 2009, at 1:08 PM, Lloyd Chambers wrote:
>
>> Is there some trick to getting a junit test to run for a module
>> during build?
>>
>> Adding a test does not seem to run. Here's a dummy I tried ("There
>> are no tests to run").
>>
>> llcMP:amx-core llc$ ls src/test/java/org/glassfish/admin/amx/test/core
>> OtherTests.java
>>
>>
>> package org.glassfish.admin.amx.test.core;
>>
>> import org.junit.Test;
>>
>> public final class OtherTests {
>> public OtherTests()
>> {
>> }
>>
>> @Test
>> public void testDummy() {
>> }
>> }
>>
>> It doesn't look any different than ImmutableTest in glassfish-api:
>>
>> package org.glassfish.api.tests;
>>
>> import org.junit.Test;
>> import junit.framework.Assert;
>> import org.glassfish.api.event.EventTypes;
>>
>> public class ImmutableTest {
>> @Test
>> public void test1() {
>>
>> EventTypes evt1 = EventTypes.create("foo");
>> EventTypes evt2 = EventTypes.create("foo");
>> EventTypes evt3 = EventTypes.create("foo34");
>>
>> Assert.assertNotSame(evt1, evt3);
>> Assert.assertEquals(evt1, evt2);
>>
>> Assert.assertTrue(evt1==evt2);
>> Assert.assertFalse(evt1==evt3);
>> }
>>
>> }
>
> Lloyd Chambers
> lloyd.chambers_at_sun.com
> GlassFish Team
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>