Class BaseTest

  • All Implemented Interfaces:
    org.assertj.core.api.InstanceOfAssertFactories
    Direct Known Subclasses:
    ComponentTest, ModuleTest, SubsystemTest, SystemTest

    public abstract class BaseTest
    extends org.assertj.core.api.Assertions
    This is the abstract base class for all tests. In most cases it will be convenient to extend this class.

    Although it does not contain abstract methods, the class itself is declared abstract to clarify its purpose.

    This class provides final methods setUp() and tearDown() which call protected methods doSetUp() and doTearDown() internally.
    Both methods doSetUp() and doTearDown() are left empty here. If some default behaviour is desired during test setup or teardown these methods should be overridden by the subclass.
    Implementations must call the super implementation. This call should always happen at the beginning of the implementation. This helps to avoid confusion of call orders.

    The following listing should clarify the intention:
     public class MyTest extends BaseTest {
    
       @Override
       protected void doSetUp() {
    
         super.doSetUp();
         // ... my code
       }
     }
     
    Additional value is provided by isInitialSetup() that may be helpful for specific implementations of doSetUp() where you want to do some cleanup only once for the test-class rather than for every test method. Unlike BeforeAll this can be used in non-static method code so you have access to injected dependencies.
    • Field Summary

      • Fields inherited from interface org.assertj.core.api.InstanceOfAssertFactories

        ARRAY, ARRAY_2D, ATOMIC_BOOLEAN, ATOMIC_INTEGER, ATOMIC_INTEGER_ARRAY, ATOMIC_INTEGER_FIELD_UPDATER, ATOMIC_LONG, ATOMIC_LONG_ARRAY, ATOMIC_LONG_FIELD_UPDATER, ATOMIC_MARKABLE_REFERENCE, ATOMIC_REFERENCE, ATOMIC_REFERENCE_ARRAY, ATOMIC_REFERENCE_FIELD_UPDATER, ATOMIC_STAMPED_REFERENCE, BIG_DECIMAL, BIG_INTEGER, BOOLEAN, BOOLEAN_2D_ARRAY, BOOLEAN_ARRAY, BYTE, BYTE_2D_ARRAY, BYTE_ARRAY, CHAR_2D_ARRAY, CHAR_ARRAY, CHAR_SEQUENCE, CHARACTER, CLASS, COLLECTION, COMPLETABLE_FUTURE, COMPLETION_STAGE, DATE, DOUBLE, DOUBLE_2D_ARRAY, DOUBLE_ARRAY, DOUBLE_PREDICATE, DOUBLE_STREAM, DURATION, FILE, FLOAT, FLOAT_2D_ARRAY, FLOAT_ARRAY, FUTURE, INPUT_STREAM, INSTANT, INT_2D_ARRAY, INT_ARRAY, INT_PREDICATE, INT_STREAM, INTEGER, ITERABLE, ITERATOR, LIST, LOCAL_DATE, LOCAL_DATE_TIME, LOCAL_TIME, LONG, LONG_2D_ARRAY, LONG_ADDER, LONG_ARRAY, LONG_PREDICATE, LONG_STREAM, MAP, OFFSET_DATE_TIME, OFFSET_TIME, OPTIONAL, OPTIONAL_DOUBLE, OPTIONAL_INT, OPTIONAL_LONG, PATH, PERIOD, PREDICATE, SHORT, SHORT_2D_ARRAY, SHORT_ARRAY, SPLITERATOR, STREAM, STRING, STRING_BUFFER, STRING_BUILDER, THROWABLE, URI_TYPE, URL_TYPE, ZONED_DATE_TIME
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseTest()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doSetUp()
      Provides initialization previous to the creation of the text fixture.
      protected void doTearDown()
      Provides clean up after tests.
      protected boolean isInitialSetup()  
      void setUp()
      Suggests to use doSetUp() method before each tests.
      static void setUpClass()
      Initializes this test class and resets initial setup flag.
      void tearDown()
      Suggests to use doTearDown() method before each tests.
      • Methods inherited from class org.assertj.core.api.Assertions

        allOf, allOf, anyOf, anyOf, as, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThatCode, assertThatExceptionOfType, assertThatIllegalArgumentException, assertThatIllegalStateException, assertThatIOException, assertThatNoException, assertThatNullPointerException, assertThatObject, assertThatThrownBy, assertThatThrownBy, assertWith, atIndex, byLessThan, byLessThan, byLessThan, byLessThan, byLessThan, byLessThan, byLessThan, byLessThan, byLessThan, catchThrowable, catchThrowableOfType, contentOf, contentOf, contentOf, contentOf, contentOf, contentOf, doesNotHave, entry, extractProperty, extractProperty, fail, fail, fail, failBecauseExceptionWasNotThrown, filter, filter, from, in, linesOf, linesOf, linesOf, linesOf, linesOf, linesOf, not, not, notIn, offset, offset, registerCustomDateFormat, registerCustomDateFormat, registerFormatterForType, setAllowComparingPrivateFields, setAllowExtractingPrivateFields, setDescriptionConsumer, setExtractBareNamePropertyMethods, setLenientDateParsing, setMaxElementsForPrinting, setMaxLengthForSingleLineDescription, setMaxStackTraceElementsDisplayed, setPrintAssertionsDescription, setRemoveAssertJRelatedElementsFromStackTrace, shouldHaveThrown, tuple, useDefaultDateFormatsOnly, useDefaultRepresentation, useRepresentation, within, within, within, within, within, within, within, within, within, withinPercentage, withinPercentage, withinPercentage, withMarginOf, withPrecision, withPrecision
    • Constructor Detail

      • BaseTest

        public BaseTest()
    • Method Detail

      • setUpClass

        @BeforeAll
        public static void setUpClass()
        Initializes this test class and resets initial setup flag.
      • setUp

        @BeforeEach
        public final void setUp()
        Suggests to use doSetUp() method before each tests.
      • tearDown

        @AfterEach
        public final void tearDown()
        Suggests to use doTearDown() method before each tests.
      • isInitialSetup

        protected boolean isInitialSetup()
        Returns:
        true if this JUnit class is invoked for the first time (first test method is called), false otherwise (if this is a subsequent invocation).
      • doSetUp

        protected void doSetUp()
        Provides initialization previous to the creation of the text fixture.
      • doTearDown

        protected void doTearDown()
        Provides clean up after tests.