Wednesday, November 15, 2017

Junit 5 Architecture



Modules in JUnit 5 :

•         junit-jupiter-api:
This module defines the API that you need to write your tests.

•         junit-platform-launcher:
This module defines the launcher API that external tool use. Launchers can be used to discover, filter, and execute tests.

•         junit-platform-engine:
This provides the API that you can use to write your own TestEngine. TestEngine is responsible for the discovery and execution of tests.

•         junit-jupiter-engine:
It is the implementation of junit-platform-engine API for JUnit 5.

•         junit-vintage-engine:
It is the implementation of junit-platform-engine API for JUnit 3 and JUnit 4.

•         junit-platform-commons:
It contains all the utilities which are used across different modules.

•         junit-platform-console:
This provides an implementation of a launcher called ConsoleLauncher. ConsoleLauncher is a stand-alone application used to launch JUnit platform from the console.

•         junit-platform-gradle-plugin:
This is a Gradle plug-in that can be used to run JUnit 5 tests.

•         junit-platform-surefire-provider: 

This module provides Maven integration for JUnit 5.




Junit 5 Sub-projects


JUnit 5 is composed of three subprojects. Each of these subprojects has multiple modules :

  • JUnit Platform: This provides a foundation for launching JVM
(Java Virtual Machine) testing frameworks. This includes a
TestEngine API that can be used to develop a testing framework
for JUnit Platform to run. It also provides a ConsoleLauncher that
build tools like Gradle and Maven can use.

  • JUnit Jupiter: This provides the new programming model for
writing tests. Also, the new extension mechanism is part of this
subproject. It implements the TestEngine API defined by JUnit
Platform so that JUnit 5 tests can be run.

  • JUnit Vintage: This provides a TestEngine implementation for
running JUnit 3 and JUnit 4 tests.

Junit 5


  • Junit 5 is rewritten in Java 8.
  • Junit 5 also called as Junit Lambda.
  • Junit 5 Support till Junit 3.8 and above.

What is JUnit


  • Junit is unit testing framework for Java.
  • It is developed by Kent Back and Erich Gamma in 1997.
  • Junit5 is recent version of Junit written on Java 8 version.
  • New Modules has been introduced in Junit5 to make more feature oriented.

Why Unit Testing



  • Software development is a Team work nowadays. So once code written by one team member should not get break by other, Junit can prevent it.
  • Agile promotes TDD Test Driven Development. It means write test code first and then write production ready code.
  • A fix done for defect should not introduces new error in code.
  • Mistake is part of human nature. Even a good programmer can write wrong code. But Junit test alerts to fix it timely.
  • TDD (Test Driven Design) helps to make code simple and reusable , it helps in designing of code.
  • Making test cases automates will reduce lot of effort to test code.
  • It helps to understand existing code.
  • Unit testing must be written before writing code and should be maintained through development life cycle.
  • Also it reduces development cost by providing test failure reports.

Unit testing provides below benefits

  • Specification of system : like what should be input and expected output and business conditions.
  • Error Detection : Timely test reports helps to catch defect .
  • Good Design : Individual modules makes easy to test.
  • Save cost and time of project.
  • Test cases itself are documents to describe expectation of code.

Good Unit test cases are 

  • Readable : Follow Java Naming conventions/comments and provides Java Doc as well.
  • Fast : It should uses mock to object to get it finish soon.
  • Independent and Isolated : less complex and easy to test.
  • Correct : Should test exact business logic of code.
  • Repeatable :For random Test data it should produce expected result even it get executed many times.

Monday, July 16, 2012

My Account Porltet-Hook Test case


Test Case 1:
Edit portal.properties in hook.
#
# Input a list of sections that will be included as part of the user form
# when updating a user in the My Account portlet.
#
users.form.my.account.main=
users.form.my.account.identification=
users.form.my.account.miscellaneous=


Yes, u r right , I am just provided no values at all, deploy it .
My Account Portlet will look like :

 

Because this information is compulsory. We cannot remove it by Hook.

Test Case 2:
Portal.properties :
users.form.my.account.main=details,password,websites
users.form.my.account.identification=phone-numbers,addresses,categorization
users.form.my.account.miscellaneous=announcements,comments

Here I moved websites to main section and categorization to in identification section .
Will it work?? Deploy Hook.

     


So websites is moves in main section and categorization is moved in identification sections.
    
      My Account Portlet Hook

Junit 5 Architecture

Modules in JUnit 5 : •         junit-jupiter-api: This module defines the API that you need to write your tests. •         ...