Most of the JUnit tests can be mechanically translated via IntelliJ (or other tools potentially). The tests that need manual migration are ones that use an expected exception in the @Test annotation and tests that use rules. I've already ported most of the JUnit 4 rules into equivalent JUnit 5 extensions, though they work a little differently (e.g., instead of invoking a rule instance to get objects from the LoggerContext, you can add a LoggerContext parameter to your test method and have it injected).
On Wed, Jan 12, 2022 at 12:46 PM Gary Gregory <garydgreg...@gmail.com> wrote: > > I happy to stick with Junit 5 convertions once we drop Junit 4, which feels > like a tediuous big job :-( > > Gafy > > On Wed, Jan 12, 2022, 13:33 Carter Kozak <cko...@ckozak.net> wrote: > > > +1 > > > > I prefer minimum visibility by default for the same reason I prefer to > > make everything final by default: It gives us more freedom to change later > > on. This doesn't directly apply to tests, but it's nice when a convention > > applies globally. > > > > Most projects don't make junit5 tests public, so there's a question of > > whether we want to be consistent with our own usage of junit4, or with > > broader usage of junit5. I prefer the latter. We could enforce it with > > error-prone for consistency, if desired. > > > > -ck > > > > On Wed, Jan 12, 2022, at 13:07, Matt Sicker wrote: > > > I'll note that the convention from JUnit 4 is to make them public; > > > JUnit 5 encourages package-private tests instead for some reason, and > > > that's the default template for JUnit 5 tests in IntelliJ. I do like > > > consistency, though! > > > > > > On Wed, Jan 12, 2022 at 11:01 AM <ggreg...@apache.org> wrote: > > > > > > > > This is an automated email from the ASF dual-hosted git repository. > > > > > > > > ggregory pushed a commit to branch release-2.x > > > > in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git > > > > > > > > commit b4a892acd1d37f355c27cde10ab1736cf1ebe315 > > > > Author: Gary Gregory <garydgreg...@gmail.com> > > > > AuthorDate: Wed Jan 12 11:58:30 2022 -0500 > > > > > > > > Our convention is to make test classes public. > > > > --- > > > > .../test/java/org/apache/logging/log4j/core/net/SmtpManagerTest.java > > | 2 +- > > > > > > .../org/apache/logging/log4j/core/net/SocketAppenderReconnectTest.java | 2 > > +- > > > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > > > > > diff --git > > a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SmtpManagerTest.java > > b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SmtpManagerTest.java > > > > index df98702..5759cf7 100644 > > > > --- > > a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SmtpManagerTest.java > > > > +++ > > b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SmtpManagerTest.java > > > > @@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test; > > > > /** > > > > * Unit tests for {@link SmtpManager}. > > > > */ > > > > -class SmtpManagerTest { > > > > +public class SmtpManagerTest { > > > > > > > > @Test > > > > void testCreateManagerName() { > > > > diff --git > > a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketAppenderReconnectTest.java > > b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketAppenderReconnectTest.java > > > > index 5fa603f..87f30dd 100644 > > > > --- > > a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketAppenderReconnectTest.java > > > > +++ > > b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/SocketAppenderReconnectTest.java > > > > @@ -55,7 +55,7 @@ import static org.junit.jupiter.api.Assertions.*; > > > > /** > > > > * Tests reconnection support of {@link > > org.apache.logging.log4j.core.appender.SocketAppender}. > > > > */ > > > > -class SocketAppenderReconnectTest { > > > > +public class SocketAppenderReconnectTest { > > > > > > > > private static final Logger LOGGER = StatusLogger.getLogger(); > > > > > > > > >