Get the name of the test case in the JUnit test class

I learned how to figure out the test method name of a JUnit test class. You can use it to grasp the test case with @Before.

Information can be obtained by adding @ org.junit.Rule to ʻorg.junit.rules.TestName` and defining the fields of the test class.

/**
 * TestName
 */
@Rule
public TestName testName = new TestName();

// want to know test case name.
System.out.println("[TestName] : " + testName.getMethodName());

It's convenient, I would like to use it from now on. For your reference.

Recommended Posts

Get the name of the test case in the JUnit test class
When you get lost in the class name
How to get the class name / method name running in Java
How to get the class name of the argument of LoggerFactory.getLogger when using SLF4J in Java
Get the result of POST in Java
[Spring Boot] Until @Autowired is run in the test class [JUnit5]
graphql-ruby: How to get the name of query or mutation in controller Note
If you want to satisfy the test coverage of private methods in JUnit
Part of the class called from the class under test in JMockit Mock method memo
Call a method of the parent class by explicitly specifying the name in Ruby
Get the class name and method name of Controller executed by HandlerInterceptor of Spring Boot
Get the path defined in Controller class of Spring boot as a list
Get the URL of the HTTP redirect destination in Java
[Kotlin] Get the argument name of the constructor by reflection
Return the execution result of Service class in ServiceResponse class
Test the contents of an Excel file with JUnit
[Java] Get the file in the jar regardless of the environment
Personal summary of the guys often used in JUnit 4
Ruby, Nokogiri: Get the element name of the selected node
Get the URL of the HTTP redirect destination in Ruby
Why the get method is needed in the Calendar class
Summarize the additional elements of the Optional class in Java 9
[Java] JUnit4 test case example
Test private methods in JUnit
Test private methods in JUnit
[JUnit] Test the thrown exception
Get the object name of the instance created by the new operator
The case that @Autowired could not be used in JUnit5
How to mock some methods of the class under test
[Java] Get date information 10 days later using milliseconds in the Date class
Get a proxy instance of the component itself in Spring Boot
Fix the file name of war to the one set in Maven
Various methods of the String class
How to get the id of PRIMAY KEY auto_incremented in MyBatis
Examine the list of timezone IDs available in the Java ZoneId class
Get the public URL of a private Flickr file in Java
Output JUnit test report in Maven
Get the ID of automatic numbering
Order of processing in the program
What are the rules in JUnit?
How to get the length of an audio file in java
[Rails] Difference in behavior between delegate and has_many-through in the case of one-to-one-to-many
Error when the member of Entity class used in SpringWebFlux is final
[Java] How to get to the front of a specific string using the String class
How to get the absolute path of a directory running in Java
I want to get the field name of the [Java] field. (Old tale tone)
Displaying the three-dimensional structure of DNA and proteins in Ruby-in the case of GR.rb
I get got errors: User must exist in the unit model test
I checked the package name referenced by the class contained in the JAR file
Get the value of enum saved in DB by Rails with attribute_before_type_cast
When the bean class name is duplicated
How to filter JUnit Test in Gradle
[Java] Get the day of the specific day of the week
Control test order in Junit4 with enumeration
Test the integrity of the aggregation using ArchUnit ②
The identity of params [: id] in rails
Get the column name from the Model instance
The story of AppClip support in Anyca
[Swift] Get the height of Safe Area
[Rails] Change the label name of f.label
How to get the date in java