Skip to content

Comments

Add JUnit 6 with JSpecify null safety pattern#65

Merged
brunoborges merged 2 commits intomainfrom
copilot/create-junit-6-slug
Feb 20, 2026
Merged

Add JUnit 6 with JSpecify null safety pattern#65
brunoborges merged 2 commits intomainfrom
copilot/create-junit-6-slug

Conversation

Copy link
Contributor

Copilot AI commented Feb 20, 2026

Adds a new tooling pattern slug comparing JUnit 5's unannotated API against JUnit 6's adoption of JSpecify @NullMarked, which makes non-null the default and surfaces null contract violations at compile time.

New pattern: tooling/junit6-with-jspecify

// JUnit 5 — no null contracts; must read source to know what's safe
class UserServiceTest {
    @Test void findUser_notFound() {
        assertNull(service.findById("missing")); // null or throws? unclear
    }
}

// JUnit 6 — @NullMarked module; @Nullable where nullable, non-null everywhere else
@NullMarked
class UserServiceTest {
    @Test void findUser_notFound() {
        @Nullable User result = service.findById("missing");
        assertNull(result); // IDE confirms null expectation
    }
}

Changes

  • content/tooling/junit6-with-jspecify.json — new pattern (id 111); highlights explicit API contracts, compile-time safety via NullAway/Error Prone/IDEs, and JSpecify as a cross-ecosystem standard shared with Spring and Guava
  • content/tooling/aot-class-preloading.jsonnext updated to tooling/junit6-with-jspecify
  • content/language/default-interface-methods.jsonprev updated to tooling/junit6-with-jspecify
  • Regenerated all site HTML and site/data/snippets.json (111 total patterns)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • medium.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>New slug for JUnit 6 with JSpecify versus JUnit 5</issue_title>
<issue_description>See article Explicit nullability and cleaner output for hints.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add new slug for JUnit 6 with JSpecify Add JUnit 6 with JSpecify null safety pattern Feb 20, 2026
Copilot AI requested a review from brunoborges February 20, 2026 08:11
@brunoborges brunoborges marked this pull request as ready for review February 20, 2026 08:13
@brunoborges brunoborges merged commit de2a615 into main Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New slug for JUnit 6 with JSpecify versus JUnit 5

2 participants