Skip to content

Commit c39b28f

Browse files
committed
Add test extension to log test method execution
1 parent 3098d84 commit c39b28f

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2024 Broadcom. All Rights Reserved.
2+
// The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
// If you have any questions regarding licensing, please contact us at
17+
18+
package com.rabbitmq.client.amqp;
19+
20+
import org.junit.jupiter.api.extension.AfterEachCallback;
21+
import org.junit.jupiter.api.extension.BeforeEachCallback;
22+
import org.junit.jupiter.api.extension.ExtensionContext;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
25+
26+
public class AmqpClientTestExtension implements BeforeEachCallback, AfterEachCallback {
27+
28+
private static final Logger LOGGER = LoggerFactory.getLogger(AmqpClientTestExtension.class);
29+
30+
@Override
31+
public void beforeEach(ExtensionContext context) {
32+
LOGGER.info(
33+
"Starting test: {}.{}",
34+
context.getTestClass().get().getSimpleName(),
35+
context.getTestMethod().get().getName());
36+
}
37+
38+
@Override
39+
public void afterEach(ExtensionContext context) {
40+
LOGGER.info(
41+
"Test finished: {}.{}",
42+
context.getTestClass().get().getSimpleName(),
43+
context.getTestMethod().get().getName());
44+
}
45+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.rabbitmq.client.amqp.AmqpClientTestExtension
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
junit.jupiter.extensions.autodetection.enabled=true

src/test/resources/logback-test.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
</encoder>
66
</appender>
77

8+
<logger name="com.rabbitmq.client.amqp.AmqpClientTestExtension" level="info" />
89
<logger name="com.rabbitmq.client.amqp" level="warn" />
910
<logger name="com.rabbitmq.client.amqp.impl.EntityRecovery" level="warn" />
1011
<logger name="com.rabbitmq.client.amqp.impl.AmqpConnection" level="warn" />

0 commit comments

Comments
 (0)