Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.pinkprogramming.javatesting.util;

public class SentenceUtil {

public static boolean isEndWithPeriodString(String inputString) {
return inputString.endsWith(".");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.pinkprogramming.javatesting.util.SentenceUtil;

public class BasicTests {

// Test 1. Numerical comparisons
@Test
@DisplayName("The vehicle should be affordable")
void vehicleShouldBeAffordable() {
Expand All @@ -17,6 +19,7 @@ void vehicleShouldBeAffordable() {
assertTrue((fuel + hullRepairs) < maxCost);
}

// Test 2. String comparisons
@Test
@DisplayName("Should end with a period.")
void sentenceEndsWithAPeriod() {
Expand All @@ -25,4 +28,21 @@ void sentenceEndsWithAPeriod() {
assertTrue(example.endsWith("."));
}

// Test 2 b. Revisit test2
// this time testing a method
// that accepts a string and returns last character
@Test
@DisplayName("Method should return true when sentence ends with period")
void shouldReturnTrueWhenSentenceEndsWithPeriod() {
String example = "Hi, my name is Polly.";
assertTrue(SentenceUtil.isEndWithPeriodString(example));
}

@Test
@DisplayName("Method should return false when sentence does not end with period")
void shouldReturnFalseWhenSentenceDoesNotEndWithPeriod() {
String example = "Hi";
assertTrue(SentenceUtil.isEndWithPeriodString(example));
}

}