[JAVA] JUnit unit test pre-processing and post-processing order

Introduction

Every time I have time to implement a unit test, I forget the order of constructor, test class pre-processing and test class post-processing, test method pre-processing, and test method post-processing, so I leave it for personal reference.

environment

--JRE System Library [JavaSE-11]

Test target

--Constructor --Test class (@BeforeClass, @AfterClass) --Test method (@Before, @After)

Test sample

スクリーンショット 2020-11-12 9.15.08.png

result

スクリーンショット 2020-11-12 9.15.55.png

When I tried it, it was a natural result, but for the time being, it seems that the number of "that ... how was the order?" At the time of unit test implementation will decrease, so I will leave it as a memo.

Recommended Posts

JUnit unit test pre-processing and post-processing order
Unit test with Junit.
WebAPI unit test and integration test with SpringBoot + Junit5, 4 patterns
Introduce RSpec and write unit test code
Control test order in Junit4 with enumeration
About designing Spring Boot and unit test environment
Mixin test cases with JUnit 5 and default methods
Try JUnit test launch
Java Unit Test Library-Artery-Sample
Use Spring Test + Mockito + JUnit 4 for Spring Boot + Spring Retry unit tests