refactoring: Added parameterization to enumeration test (#1698)
Signed-off-by: Elvys Soares <eas5@cin.ufpe.br> Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
This commit is contained in:
parent
323dd63e66
commit
af0ccdc6e1
@ -38,6 +38,11 @@
|
|||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -25,7 +25,8 @@ package com.iluwatar.multiton;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.EnumSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author anthony
|
* @author anthony
|
||||||
@ -37,15 +38,14 @@ class NazgulEnumTest {
|
|||||||
* Check that multiple calls to any one of the instances in the multiton returns
|
* Check that multiple calls to any one of the instances in the multiton returns
|
||||||
* only that one particular instance, and do that for all instances in multiton
|
* only that one particular instance, and do that for all instances in multiton
|
||||||
*/
|
*/
|
||||||
@Test
|
@ParameterizedTest
|
||||||
void testTheSameObjectIsReturnedWithMultipleCalls() {
|
@EnumSource
|
||||||
for (var i = 0; i < NazgulEnum.values().length; i++) {
|
void testTheSameObjectIsReturnedWithMultipleCalls(NazgulEnum nazgulEnum) {
|
||||||
var instance1 = NazgulEnum.values()[i];
|
var instance1 = nazgulEnum;
|
||||||
var instance2 = NazgulEnum.values()[i];
|
var instance2 = nazgulEnum;
|
||||||
var instance3 = NazgulEnum.values()[i];
|
var instance3 = nazgulEnum;
|
||||||
assertSame(instance1, instance2);
|
assertSame(instance1, instance2);
|
||||||
assertSame(instance1, instance3);
|
assertSame(instance1, instance3);
|
||||||
assertSame(instance2, instance3);
|
assertSame(instance2, instance3);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user