pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
10+ messages / 2 participants
[nested] [flat]

* [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-01 16:23  "vlsi (@vlsi)" <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-01 16:23 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

JUnit 5.13 brings @ParameterizedClass which makes it way easier to migrate JUnit 4 @Parameterized tests to JUnit 5.

Notes for the reviewers:
* I used IDEA's inspection to automatically convert JUnit4 assertions and assumptions to JUnit5
* I used IDEA's "simplify assertion" to automatically convert cases like `assertTrue(!x)` into `assertFalse(x)`
* `@ParameterizedClass` is experimental in JUnit 5.13, however, it feels so good to finally drop JUnit4 from the dependencies so we no longer have multiple `@Test` annotations

RedHat Bugzilla regarding JUnit 5.13 update: https://bugzilla.redhat.com/show_bug.cgi?id=2276648

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-01 21:02  "davecramer (@davecramer)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: davecramer (@davecramer) @ 2025-06-01 21:02 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

I was wondering how you did this. I'm curious how well an LLM would have done 

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 07:34  "vlsi (@vlsi)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-02 07:34 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The procedure was like
* remove `import org.junit.Test;`
* autofix "import `@Test`" with junit5
* autofix "JUnit4 assertions used in JUnit5 test"
* make all Assertion imports static
* wrap long assertion lines if needed <-- this was manual
* replace `@RunWith(Parameterized.class)` with `@ParameterizedClass`, add `@MethodSource("data")`

My guess is that with an LLM I would not have any confidence in the result: JUnit4 and JUnit5 have different order of arguments for `assertEquals`, and sometimes the code was using the wrong order.

As I migrated the code I did not bother understanding the diffs as long as it compiled.


^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 08:00  "vlsi (@vlsi)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-02 08:00 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

A funny finding: `AutoRollbackTestSuite` was not executed during the CI tests as the test name was wrong.

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 09:02  "davecramer (@davecramer)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: davecramer (@davecramer) @ 2025-06-02 09:02 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

> The procedure was like
> 
> * remove `import org.junit.Test;`
> * autofix "import `@Test`" with junit5
> * autofix "JUnit4 assertions used in JUnit5 test"
> * make all Assertion imports static
> * wrap long assertion lines if needed <-- this was manual
> * replace `@RunWith(Parameterized.class)` with `@ParameterizedClass`, add `@MethodSource("data")`
> 
> My guess is that with an LLM I would not have any confidence in the result: JUnit4 and JUnit5 have different order of arguments for `assertEquals`, and sometimes the code was using the wrong order.
I've had pretty positive results with an LLM


^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 09:02  "davecramer (@davecramer)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: davecramer (@davecramer) @ 2025-06-02 09:02 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

> A funny finding: `AutoRollbackTestSuite` was not executed during the CI tests as the test name was wrong.

Good catch!

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 09:43  "vlsi (@vlsi)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-02 09:43 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Copr build fails as it still ships with a much older junit: `Installing junit5-0:5.10.2-14`

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 09:54  "vlsi (@vlsi)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-02 09:54 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

The following test still requires JUnit4 as classloader-leak-prevention [supports JUnit 4 only](https://github.com/mjiderhamn/classloader-leak-prevention/issues/150):

```java
@RunWith(JUnitClassloaderRunner.class)
@LeakPreventor(DriverSupportsClassUnloadingTest.LeakPreventor.class)
@PackagesLoadedOutsideClassLoader(
    packages = {"java.", "javax.", "jdk.", "com.sun.", "sun.", "org.w3c", "org.junit.", "junit.",
        "se.jiderhamn."}
)
class DriverSupportsClassUnloadingTest {
```

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-02 10:47  "vlsi (@vlsi)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-02 10:47 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

I've implemented all the changes. Now all the core tests use JUnit5 only.
I've added a dependency constraint that would fail the build should JUnit4 appear as a direct or indirect dependency.


^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass
@ 2025-06-04 18:06  "vlsi (@vlsi)" <[email protected]>
  8 siblings, 0 replies; 10+ messages in thread

From: vlsi (@vlsi) @ 2025-06-04 18:06 UTC (permalink / raw)
  To: pgjdbc/pgjdbc <[email protected]>

Should we wait for Fedora to integrate JUnit 5.13, or could we merge this with Copr still failing?

^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2025-06-04 18:06 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-06-01 16:23 [pgjdbc/pgjdbc] PR #3652: chore: update JUnit to 5.13, use @ParameterizedClass "vlsi (@vlsi)" <[email protected]>
2025-06-01 21:02 ` "davecramer (@davecramer)" <[email protected]>
2025-06-02 07:34 ` "vlsi (@vlsi)" <[email protected]>
2025-06-02 08:00 ` "vlsi (@vlsi)" <[email protected]>
2025-06-02 09:02 ` "davecramer (@davecramer)" <[email protected]>
2025-06-02 09:02 ` "davecramer (@davecramer)" <[email protected]>
2025-06-02 09:43 ` "vlsi (@vlsi)" <[email protected]>
2025-06-02 09:54 ` "vlsi (@vlsi)" <[email protected]>
2025-06-02 10:47 ` "vlsi (@vlsi)" <[email protected]>
2025-06-04 18:06 ` "vlsi (@vlsi)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox