I'm trying to use mycilia for testing and according to the testng
example here http://code.mycila.com/wiki/MycilaTesting I should be
able to just extend AbstractMycilaTestNGTest and annotate with my
GuiceContext However that abstract class doesn't seem to help me,
instead I have to use the other approarch shown in each of my test
classes:
@BeforeClass
public void setup() {
TestSetup.setup(this);
}
I was hoping I could just have all my classes extend a BaseTest class
which extends AbstractMycilaTestNGTest and everything would be fine,
but it's not working for me (None of my Injections take place nor do I
see my Module even loaded.)
I was hoping to just extends my tests from:
@GuiceContext(OndpServicesTestModule.class)
public abstract class BaseTest extends AbstractMycilaTestNGTest {
}
(As a side note even when I push up the @BeforeClass implementation
into this base class, things aren't working. It seems odd that I have
to actually use the @BeforeClass setUp method in my actual concrete
Test classes and not in the BaseTest class?)
I'm hopefully missing something very simple, but I'm stumped right now.
Just make sure your factory class is listed first and it runs great
(the document above has a typo in the class name or the name has since
changed since that was written... the class is AbstractObjectFactory
not AbstractTestObjectFactory.)
--
Rick
Ok, I'll post my setup in an issue's list. Thanks.
In regard to inheritence. I was using a BaseTestClass for a
@BeforeMethod and @AfterMethod which would initialize a time and the
afterMethod would log the time it took.
I also put my logger initialization in the base class. Just one less
thing to always have to put in each class.
I'm sure some AOP stuff could help out but using a BaseTest class for
this simple stuff seems to work fine. I'm open for some other
approaches.
Hi,
I don't know how you setup your environment, but this usage has been
tested and works well: In example:
@GuiceContext(AModule.class)
public final class ExtendTest extends AbstractMycilaTestNGTest {
@Inject
@Named("service1")
Service service1;
@Test
public void test_inject() {
assertEquals(service1.go(), "go1");
}
}
If you need some help, i suggest you post fore information on your
setup and the libraries you are using on your classpath at
http://code.google.com/p/mycila/issues/list so that we can help you.
Nevertheless, i hardly advise to not use inheritance even for test
classes since it leads to junk classes having an accumulation of
methods which leads to tests that are time consuming to maintain.
>>>
>>> If you need some help, i suggest you post fore information on your
>>> setup and the libraries you are using on your classpath at
>>> http://code.google.com/p/mycila/issues/list so that we can help you.
>>> Nevertheless, i hardly advise to not use inheritance even for test
>>> classes since it leads to junk classes having an accumulation of
>>> methods which leads to tests that are time consuming to maintain.
>
> Or did you mean, you "strongly" advise against inheritance? In which case, I
> agree.
Yea you're both on the same page there.
Just curious though how would you recommend setting up a common
@BeforeMethod @AterMethod type of behavior? Is it at least ok to push
that into a class my tests classes can extend so they all have those
method implementations inherited?
Thanks
--
Rick
> Just make sure your factory class is listed first and it runs great
> (the document above has a typo in the class name or the name has since
> changed since that was written... the class is AbstractObjectFactory
> not AbstractTestObjectFactory.)
>
--
My LinkedIn profile: http://www.linkedin.com/in/simonetripodi
My GoogleCode profile: http://code.google.com/u/simone.tripodi/
My Picasa: http://picasaweb.google.com/simone.tripodi/
My Tube: http://www.youtube.com/user/stripodi
My Del.icio.us: http://del.icio.us/simone.tripodi