[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
AW: [riena-dev] Test friendly LOGGER pattern
|
Maybe we can extend the TestCollector with a new annotation @PlugInTest...? Then we could have two additional test suites AllPlugInTests and AllNonPlugInTests.
Would that be much faster or is the speed gain only noticeable for single tests?
Greetings,
Carsten
Von: riena-dev-bounces@xxxxxxxxxxx [mailto:riena-dev-bounces@xxxxxxxxxxx] Im Auftrag von Elias Volanakis
Gesendet: Donnerstag, 5. März 2009 01:59
An: Riena Developers list
Betreff: [riena-dev] Test friendly LOGGER pattern
Just a quick tip:
If you use static LOGGER fields, I recommend using the pattern (b) below. It avoids a NPE exception when calling Activator.getDefault().getLogger(), which usually happens when running test suites as "plain" junit tests.
(a) Problematic with Junit:
public final class MyClass {
private static final Logger LOGGER = Activator.getDefault().getLogger(ImageStore.class);
(b) Works well with Junit:
public final class MyClass {
private static final Logger LOGGER;
static {
if (Activator.getDefault() != null) {
LOGGER = Activator.getDefault().getLogger(MyClass.class);
} else {
LOGGER = new ConsoleLogger(MyClass.class.getName());
}
}
I know that some test cases must be run as "plug-in" tests, but I usually run individual test cases for stuff I'm working on as "regular" unit-tests, because they start much faster :-)
Viele Gruesse,
Elias.