Skip to content

Commit

Permalink
Enable and show test output
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun Prasaad committed Jul 7, 2024
1 parent 7ddad8f commit 72544d3
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,108 @@ The tests and code are also developed [incrementally](https://github.com/arunbea

[JUnit docs](https://junit.org/junit5/docs/current/user-guide/#writing-tests-display-name-generator) showing these naming conventions

### Test Output

```
% ./gradlew clean build
> Task :test
org.example.LeapYearCalculatorSpec
A year is not supported
Test A year is not supported -> if it is zero PASSED
A year is not supported -> if it is negative (int)
Test [1] -1 PASSED
Test [2] -4 PASSED
Test [3] -100 PASSED
Test [4] -400 PASSED
Test [5] -2147483648 PASSED
A year is supported
A year is supported -> if it is positive (int)
Test [1] 1 PASSED
Test [2] 2147483647 PASSED
A year is not a leap year
A year is not a leap year -> if it is divisible by 100 but not by 400 (int)
Test [1] 2100 PASSED
Test [2] 1900 PASSED
Test [3] 100 PASSED
A year is not a leap year -> if it is not divisible by 4 (int)
Test [1] 2022 PASSED
Test [2] 2019 PASSED
Test [3] 1999 PASSED
Test [4] 1 PASSED
A year is a leap year
A year is a leap year -> if it is divisible by 400 (int)
Test [1] 2000 PASSED
Test [2] 1600 PASSED
Test [3] 400 PASSED
A year is a leap year -> if it is divisible by 4 but not by 100 (int)
Test [1] 2004 PASSED
Test [2] 1984 PASSED
Test [3] 4 PASSED
org.example.QueueSpecTests
A non empty queue
Test A non empty queue -> becomes shorter when dequeued PASSED
Test A non empty queue -> dequeues values in order enqueued PASSED
A non empty queue -> that is full
Test A non empty queue -> that is full -> ignores further enqueued values PASSED
Test A non empty queue -> that is full -> becomes non full when dequeued PASSED
A non empty queue -> that is not full
Test A non empty queue -> that is not full -> becomes longer when value enqueued PASSED
Test A non empty queue -> that is not full -> becomes full when enqueued up to capacity PASSED
An_empty_queue
Test becomes_non_empty_when_value_enqueued() PASSED
Test dequeues_an_empty_optional() PASSED
A new queue
Test A new queue -> preserves positive bounding capacity PASSED
Test A new queue -> is empty PASSED
Test A new queue -> rejects a zero bounding capacity PASSED
Test A new queue -> rejects a negative bounding capacity PASSED
org.example.StackTests
A non empty stack
Test A non empty stack -> becomes deeper by retaining a pushed item as its top PASSED
Test A non empty stack -> on popping reveals tops in reverse order of pushing PASSED
An empty stack
Test An empty stack -> acquires depth by retaining a pushed item as its top PASSED
Test An empty stack -> throws when popped PASSED
Test An empty stack -> throws when queried for its top item PASSED
A new stack
Test A new stack -> is empty PASSED
SUCCESS: Executed 39 tests in 1.8s
```
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("java")
id("com.adarshr.test-logger") version "4.0.0"
}

group = "org.example"
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/example/QueueSpecTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.example;

import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.IndicativeSentencesGeneration;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

Expand All @@ -9,6 +11,10 @@
class QueueSpecTests {

@Nested
@IndicativeSentencesGeneration(
separator = " -> ",
generator = DisplayNameGenerator.ReplaceUnderscores.class
)
class A_new_queue {

@Test
Expand Down Expand Up @@ -63,6 +69,10 @@ void becomes_non_empty_when_value_enqueued() {
}

@Nested
@IndicativeSentencesGeneration(
separator = " -> ",
generator = DisplayNameGenerator.ReplaceUnderscores.class
)
class A_non_empty_queue {

@Nested
Expand Down

0 comments on commit 72544d3

Please sign in to comment.