JUnit5 vs JUnit4

JUnit5 is a successor of the JUnit4 testing framework. JUnit5 introduces some notable new features:

  • Changes to annotations (JUnit4 -> JUnit5):
@BeforeClass -> @BeforeAll @Before -> @BeforeEach 

@AfterClass -> @AfterAll @After -> @AfterEach 

@Ignore -> @Disable


  • Tags for tagging and filtering via @Tag  annotation
  • Parameterized tests with @ParameterizedTest  annotation and a arguments source (@ValueSource , @CSVFileSource , @MethodSource , @EnumSource )
@ValueSource(strings = { "Hello", "World" }) 
void test(String argument) {


  • Repeated tests with @RepeatedTest  annotation
  • Dynamic tests – Tests generated via the factory method annotated with @TestFactory
Collection<DynamicTest> testFactory() {
    return Arrays.asList(
       dynamicTest("Test #1", () -> assertTrue(true)),
       dynamicTest("Test #2", () -> assertEquals(4, 2 * 2))


Contextual Components

When using component-based architecture in the frontend, contextual components are wrapper components. They can act either as presentational or container components with an extended capability of passing a data up via yield functionality. One example, in Ember, would be a checkbox list:

// components/ui-checkbox-list.hbs (component template)
{{#each items as |item|}}
   {{yield item}}


// Usage in other parts of the application

{{ui-checkbox-list items=_checkboxItems as |item|}}
{{ui-checkbox-item item=item}}


“JUnits 4, 5 and Contextual Components” Tech Bite was brought to you by Kenan Klisura, Lead Software Engineer at Atlantbh. 

Tech Bites are tips, tricks, snippets or explanations about various programming technologies and paradigms, which can help engineers with their everyday job.

Software DevelopmentTech Bites
February 23, 2024

Background Jobs in Elixir – Oban

When and why do we need background jobs? Nowadays, background job processing is indispensable in the world of web development. The need for background jobs stems from the fact that synchronous execution of time-consuming and resource-intensive tasks would heavily impact an application's  performance and user experience.  Even though Elixir is…
QA/Test AutomationTech Bites
December 22, 2023

Selenium Grid 4 with Docker

Introduction When talking about automation testing, one of the first things that comes to mind is Selenium. Selenium is a free, open-source automated testing framework used to validate web applications across different browsers and platforms. It is not just a single tool but a suite of software. Every component of…

Want to discuss this in relation to your project? Get in touch:

Leave a Reply