File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
documentation/src/docs/asciidoc Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ endif::[]
240
240
:API: https://apiguardian-team.github.io/apiguardian/docs/current/api/[@API]
241
241
:API_Guardian: https://github.com/apiguardian-team/apiguardian[@API Guardian]
242
242
:AssertJ: https://assertj.github.io/doc/[AssertJ]
243
+ :Checkstyle: https://checkstyle.sourceforge.io[Checkstyle]
243
244
:DiscussionsQA: https://github.com/junit-team/junit-framework/discussions/categories/q-a[Q&A category on GitHub Discussions]
244
245
:Hamcrest: https://hamcrest.org/JavaHamcrest/[Hamcrest]
245
246
:Jimfs: https://google.github.io/jimfs/[Jimfs]
Original file line number Diff line number Diff line change @@ -519,6 +519,32 @@ include::{testDir}/example/HamcrestAssertionsDemo.java[tags=user_guide]
519
519
Naturally, legacy tests based on the JUnit 4 programming model can continue using
520
520
`org.junit.Assert#assertThat`.
521
521
522
+ [TIP]
523
+ .Excluding Jupiter’s Assertions From a Project’s Classpath
524
+ ====
525
+ If you would like to enforce that all your tests use a certain third-party assertion
526
+ library instead of Jupiter's, you can set up a rule using {Checkstyle} or another static
527
+ analysis tool that fails the build if Jupiter's `Assertions` class is used.
528
+
529
+ [source,xml]
530
+ ----
531
+ <?xml version="1.0" encoding="UTF-8"?>
532
+ <!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
533
+ <module name="Checker">
534
+ <property name="severity" value="error" />
535
+ <module name="TreeWalker">
536
+ <module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
537
+ <property name="id" value="jupiterAssertions"/>
538
+ <property name="maximum" value="0"/>
539
+ <property name="format" value="org\.junit\.jupiter\.api\.(Assertions|Assumptions)\."/>
540
+ <property name="message" value="Jupiter Assertions/Assumptions should not be used in this project. Please use ... instead."/>
541
+ <property name="ignoreComments" value="true"/>
542
+ </module>
543
+ </module>
544
+ </module>
545
+ ----
546
+ ====
547
+
522
548
[[writing-tests-assumptions]]
523
549
=== Assumptions
524
550
You can’t perform that action at this time.
0 commit comments