forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
45 additions
and
50 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
11 changes: 5 additions & 6 deletions
11
gradle-6/dependency-constraints/src/test/java/com/baeldung/gradle/RxHelloWorldUnitTest.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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
package com.baeldung.gradle; | ||
|
||
import static com.baeldung.gradle.RxHelloWorld.hello; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static com.baeldung.gradle.RxHelloWorld.hello; | ||
|
||
/** Unit test for {@link RxHelloWorld}. */ | ||
final class RxHelloWorldUnitTest { | ||
|
||
@Test | ||
void it_emits_hello_world_values() { | ||
hello().test().assertValues("hello", "world").assertComplete(); | ||
} | ||
@Test void it_emits_hello_world_values() { | ||
hello().test().assertValues("hello", "world").assertComplete(); | ||
} | ||
} |
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
30 changes: 14 additions & 16 deletions
30
...i-spi/src/testFixtures/java/com/baeldung/fibonacci/FibonacciSequenceGeneratorFixture.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 |
---|---|---|
@@ -1,31 +1,29 @@ | ||
package com.baeldung.fibonacci; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Reusable test fixture for {@link FibonacciSequenceGenerator} implementations. Tests will be | ||
* skipped if no such implementation exists. | ||
*/ | ||
public interface FibonacciSequenceGeneratorFixture { | ||
|
||
/** @return the implementation of {@link FibonacciSequenceGenerator} to test. Must not be null */ | ||
FibonacciSequenceGenerator provide(); | ||
/** @return the implementation of {@link FibonacciSequenceGenerator} to test. Must not be null */ | ||
FibonacciSequenceGenerator provide(); | ||
|
||
@Test | ||
default void when_sequence_index_is_negative_then_throws() { | ||
final FibonacciSequenceGenerator generator = provide(); | ||
assertThrows(IllegalArgumentException.class, () -> generator.generate(-1)); | ||
} | ||
@Test default void when_sequence_index_is_negative_then_throws() { | ||
final FibonacciSequenceGenerator generator = provide(); | ||
assertThrows(IllegalArgumentException.class, () -> generator.generate(-1)); | ||
} | ||
|
||
@Test | ||
default void when_given_index_then_generates_fibonacci_number() { | ||
final FibonacciSequenceGenerator generator = provide(); | ||
final int[] sequence = {0, 1, 1, 2, 3, 5, 8}; | ||
for (int i = 0; i < sequence.length; i++) { | ||
assertEquals(sequence[i], generator.generate(i)); | ||
@Test default void when_given_index_then_generates_fibonacci_number() { | ||
final FibonacciSequenceGenerator generator = provide(); | ||
final int[] sequence = { 0, 1, 1, 2, 3, 5, 8 }; | ||
for (int i = 0; i < sequence.length; i++) { | ||
assertEquals(sequence[i], generator.generate(i)); | ||
} | ||
} | ||
} | ||
} |