in jest, we can set the title or name or description for the specific test. For simple example like below:
const sum = require('./sum');
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
and the test will give output
PASS ./sum.test.js
✓ adds 1 + 2 to equal 3 (5ms)
you can find more about jest here: https://jestjs.io/docs/getting-started
Then, how to do it in spring? Is that possible? Thanks
Assuming sum method is defined somewhere, here is the code
@Test
@DisplayName("adds 1 + 2 to equal 3")
void test() {
assertEquals(3, sum(1, 2));
}
If you are using junit framework for writing test cases for spring boot application, @DisplayName annotation is the answer for your use case. It is introduced from version 5 of junit and the below maven dependency is enough to use it in your test cases.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.