Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrating to JUnit5
  • Loading branch information
charlesfinley committed Mar 4, 2021
commit abbd3c83682df606df56611aa045cc33122b5608
5 changes: 2 additions & 3 deletions arrange-act-assert/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
<artifactId>arrange-act-assert</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

package com.iluwatar.arrangeactassert;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Arrange/Act/Assert (AAA) is a pattern for organizing unit tests. It is a way to structure your
Expand All @@ -51,10 +51,11 @@
* change and one reason to fail. In a large and complicated code base, tests that honor the single
* responsibility principle are much easier to troubleshoot.
*/
public class CashAAATest {

class CashAAATest {

@Test
public void testPlus() {
void testPlus() {
//Arrange
var cash = new Cash(3);
//Act
Expand All @@ -64,7 +65,7 @@ public void testPlus() {
}

@Test
public void testMinus() {
void testMinus() {
//Arrange
var cash = new Cash(8);
//Act
Expand All @@ -75,7 +76,7 @@ public void testMinus() {
}

@Test
public void testInsufficientMinus() {
void testInsufficientMinus() {
//Arrange
var cash = new Cash(1);
//Act
Expand All @@ -86,7 +87,7 @@ public void testInsufficientMinus() {
}

@Test
public void testUpdate() {
void testUpdate() {
//Arrange
var cash = new Cash(5);
//Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@

package com.iluwatar.arrangeactassert;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* ({@link CashAAATest}) is an anti-example of AAA pattern. This test is functionally correct, but
* with the addition of new feature, it needs refactoring. There are an awful lot of steps in that
* with the addition of a new feature, it needs refactoring. There are an awful lot of steps in that
* test method, but it verifies the class' important behavior in just eleven lines. It violates the
* single responsibility principle. If this test method failed after a small code change, it might
* take some digging to discover why.
*/
public class CashAntiAAATest {

class CashAntiAAATest {

@Test
public void testCash() {
void testCash() {
//initialize
var cash = new Cash(3);
//test plus
Expand Down