Justify JEE

Justify

[This page intended for Software Engineers; a less technical perspective may be viewed as JUST.]

PED Central is the home for the open-source “Justify” suite for JUnit testing. Justify modules support “real” (functionally equivalent) services running within the JUnit JVM for optimal performance minimizing the need for mock testing.

Regardless of your JUnit experience, you’ll appreciate the 100% fluent rule-based API for configuration. In addition, powerful custom assertions compliment specific Java technologies such as:

  • Justify Core
  • CDI (v1.x)
  • JPA (v2.x)
  • REST (v2.x)

Justify is coded using the PED Unified Pattern Language to maximize expressiveness (readability). This sample JUnit test method exposes the extended testing life-cycle available when using Justify:

/*
 * [Licensed per the Open Source "MIT License".]
 *
 * Copyright (c) 2006 - 2017 by
 * Global Technology Consulting Group, Inc. at
 * http://gtcGroup.com
 */

package com.gtcgroup.justify;

/**
 * Test Class
 */
public class ExtendedLifeCycleTest {

@Rule
 public JstRuleChain ruleChain = JstRuleChain.outerRule(true)
  .around(FirstConfigurationRule.withRequiredParameters())
  .around(SecondConfigurationRule.withRequiredParameters());

@AfterClass
 public static void afterClass() {
     System.out.println("\t09 - @AfterClass");
 }

@BeforeClass
 public static void beforeClass() {
    System.out.println("\n\t01 - @BeforeClass");
 }

@After
 public void after() 
    System.out.println("\t06 - @After");
 }

@Before
 public void before() 
    System.out.println("\n\t04 - @Before");
 }

@Test
 public void displayTestingLifeCycle() {
    System.out.println("\t05 - Test Method");
 }

The console listing for the above test class follows. In support of test method isolation, most Justify rules execute an afterTM() method to return the configuration to its prior state.

01 - @BeforeClass

02 - FirstConfigureRule.beforeTM()
03 - SecondConfigeRule.beforeTM()

****************************************************
* Welcome to the JUnit Strategy for Testing [JUST] *
****************************************************

*** Test Method Begin: 
04 - @Before
05 - Test Method
06 - @After
07 - SecondConfigurationRule.afterTM()
08 - FirstConfigurationRule.afterTM()

*** Test Method End [Succeeded .653 ms]:
Active Rule(s): [FirstConfigurationRule] [SecondConfigurationRule]

09 - @AfterClass
The following demonstration classes features the fluent rule-based API for configuration with powerful custom assertions:
 
 
If required, a light-weight JstManagedBeanRunner class provides support for a JUnit test containing a CDI Interceptor: 
 
 
Enough chatter, let’s get coding!