-
-
Notifications
You must be signed in to change notification settings - Fork 767
Add @DisplayName annotation to 3 Test files #2980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Disabled; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.Random; | ||
|
|
@@ -14,54 +15,55 @@ public void setUp() { | |
| bankAccount = new BankAccount(); | ||
| } | ||
|
|
||
| @DisplayName("Newly opened account has empty balance") | ||
| @Test | ||
| public void newlyOpenedAccountHasEmptyBalance() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
|
|
||
| assertThat(bankAccount.getBalance()).isEqualTo(0); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Deposit into account") | ||
| @Test | ||
| public void singleDeposit() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(100); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’d be preferred if these empty lines were left as-is in each test, no need to remove them. |
||
| assertThat(bankAccount.getBalance()).isEqualTo(100); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Deposit into account several times") | ||
| @Test | ||
| public void multipleDeposits() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(100); | ||
| bankAccount.deposit(50); | ||
|
|
||
| assertThat(bankAccount.getBalance()).isEqualTo(150); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Withdraw some money") | ||
| @Test | ||
| public void withdrawOnce() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(100); | ||
| bankAccount.withdraw(75); | ||
|
|
||
| assertThat(bankAccount.getBalance()).isEqualTo(25); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Withdraw entire balance") | ||
| @Test | ||
| public void withdrawTwice() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(100); | ||
| bankAccount.withdraw(80); | ||
| bankAccount.withdraw(20); | ||
|
|
||
| assertThat(bankAccount.getBalance()).isEqualTo(0); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Can do multiple operations sequentially") | ||
| @Test | ||
| public void canDoMultipleOperationsSequentially() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
|
|
@@ -70,33 +72,33 @@ public void canDoMultipleOperationsSequentially() throws BankAccountActionInvali | |
| bankAccount.withdraw(200); | ||
| bankAccount.deposit(60); | ||
| bankAccount.withdraw(50); | ||
|
|
||
| assertThat(bankAccount.getBalance()).isEqualTo(20); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot get balance of closed account") | ||
| @Test | ||
| public void cannotCheckBalanceOfClosedAccount() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.close(); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(bankAccount::getBalance) | ||
| .withMessage("Account closed"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot deposit money into closed account") | ||
| @Test | ||
| public void cannotDepositIntoClosedAccount() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.close(); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(() -> bankAccount.deposit(50)) | ||
| .withMessage("Account closed"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot deposit money into unopened account") | ||
| @Test | ||
| public void cannotDepositIntoUnopenedAccount() { | ||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
|
|
@@ -105,17 +107,18 @@ public void cannotDepositIntoUnopenedAccount() { | |
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot withdraw money from closed account") | ||
| @Test | ||
| public void cannotWithdrawFromClosedAccount() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.close(); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(() -> bankAccount.withdraw(50)) | ||
| .withMessage("Account closed"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot close unopened account") | ||
| @Test | ||
| public void cannotCloseAnAccountThatWasNotOpened() { | ||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
|
|
@@ -124,59 +127,60 @@ public void cannotCloseAnAccountThatWasNotOpened() { | |
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot open already opened account") | ||
| @Test | ||
| public void cannotOpenAnAlreadyOpenedAccount() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(bankAccount::open) | ||
| .withMessage("Account already open"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Reopened account does not retain balance") | ||
| @Test | ||
| public void reopenedAccountDoesNotRetainBalance() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(50); | ||
| bankAccount.close(); | ||
| bankAccount.open(); | ||
|
|
||
| assertThat(bankAccount.getBalance()).isEqualTo(0); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot withdraw more than was deposited") | ||
| @Test | ||
| public void cannotWithdrawMoreThanWasDeposited() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(25); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(() -> bankAccount.withdraw(50)) | ||
| .withMessage("Cannot withdraw more money than is currently in the account"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot withdraw negative amount") | ||
| @Test | ||
| public void cannotWithdrawNegativeAmount() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
| bankAccount.deposit(100); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(() -> bankAccount.withdraw(-50)) | ||
| .withMessage("Cannot deposit or withdraw negative amount"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Cannot deposit negative amount") | ||
| @Test | ||
| public void cannotDepositNegativeAmount() throws BankAccountActionInvalidException { | ||
| bankAccount.open(); | ||
|
|
||
| assertThatExceptionOfType(BankAccountActionInvalidException.class) | ||
| .isThrownBy(() -> bankAccount.deposit(-50)) | ||
| .withMessage("Cannot deposit or withdraw negative amount"); | ||
| } | ||
|
|
||
| @Disabled("Remove to run test") | ||
| @DisplayName("Can handle concurrent transactions") | ||
| @Test | ||
| public void canHandleConcurrentTransactions() throws BankAccountActionInvalidException, InterruptedException { | ||
| bankAccount.open(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've opened issue #2971 with all the details.
As per the discussion there, the
DisplayNames should be aligned exactly with thecanonical-data.jsonin theproblem-specificationsrepo, please make sure to follow that!