-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise "Exception Handling" section of User Guide
See #3780
- Loading branch information
Showing
6 changed files
with
158 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
documentation/src/test/java/example/exception/FailedAssertionDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2015-2024 the original author or authors. | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License v2.0 which | ||
* accompanies this distribution and is available at | ||
* | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
*/ | ||
|
||
package example.exception; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import example.util.Calculator; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import extensions.ExpectToFail; | ||
|
||
class FailedAssertionDemo { | ||
|
||
// tag::user_guide[] | ||
private final Calculator calculator = new Calculator(); | ||
|
||
// end::user_guide[] | ||
|
||
@ExpectToFail | ||
// tag::user_guide[] | ||
@Test | ||
void failsDueToUncaughtAssertionError() { | ||
// The following incorrect assertion will cause a test failure. | ||
// The expected value should be 2 instead of 99. | ||
assertEquals(99, calculator.add(1, 1)); | ||
} | ||
// end::user_guide[] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters