-1

Would it be safe to say that JUnit processes all and only the annotated members in the test-class and sees the rest as plain Java code-- Doesn't look at the un-annotated members.

I haven't gone far deep into JUnit-- yet, but from what i see so far, this is how it is. Looking to pin it down if it's a general case.

//===================================

ADD: see the use of its ExpectedException for instance. It's "seeing" its ExpectedException object and setting aside the exception object it's holding when that ExceptionObject is annotated with @Rule. See How do you assert that a certain exception is thrown in JUnit 4 tests?.

If you comment out @Rule, the ExceptionObject declared and instantiated there is a plain class member, just as any other class member-- nothing to do with JUnit this time. JUnit not minding it-- seeing that exception and terminating when that exception occurs.

Looking to see whether this a general rule-- how JUnit operates while working on the code.

Community
  • 1
  • 1
Roam
  • 4,831
  • 9
  • 43
  • 72

1 Answers1

0

In general this is true for JUnit 4 (except constructors). But don't rely on it. Mostly JUnit uses TestClass objects, which only give access to methods and fields with annotations.

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72