Skip to content

Instantly share code, notes, and snippets.

View b1a9id's full-sized avatar
🍻

Ryosuke Uchitate b1a9id

🍻
View GitHub Profile
class CsvFileSourceParameterizedTest {
/**
* CSV File Source
*/
@ParameterizedTest
@CsvFileSource(resources = "test.csv")
void csvFileSource(String first, int second) {
assertNotNull(first);
assertNotEquals(0, second);
}
class CsvSourceParameterizedTest {
/**
* CSV Source
*/
@ParameterizedTest
@CsvSource({"foo, bar", "foo, 'bar, hoge'", "foo, ''", "foo, "})
void csvSource(String first, String second) {
System.out.println(String.format("first: %s, second: %s", first, second));
}
}
class ParameterizedTestDemo {
@ParameterizedTest
@EnumSource(Gender.class)
void enumSourceAll(Gender gender) {
assertTrue(Arrays.asList(Gender.values()).contains(gender));
}
@ParameterizedTest
@EnumSource(value = Gender.class, names = {"MAN", "WOMAN"})
void enumSourceInclude(Gender gender) {
public enum Gender {
MAN, WOMAN
}
public class Person {
private String firstName;
private String lastName;
private int age;
private Gender gender;
class StringsValueParameterizedTestDemo {
private Person person1;
private Person person2;
@BeforeEach
void beforeEach() {
person1 = new Person("Ryosuke", "Uchitate", 27, Gender.MAN);
person2 = new Person("Taro", "Uchitate", 20, Gender.MAN);
}
class PageWrapperTest {
private PageWrapper pageWrapper;
@Mock
private Page page;
private Method initPaginationMethod;
private int totalPages;
@b1a9id
b1a9id / PageWrapper.java
Last active January 16, 2018 10:44
ページネーション作成メソッド
private List<Integer> initPagination(int paginationSize) {
if (getTotalPages() < paginationSize) {
return IntStream.range(0, paginationSize)
.boxed()
.collect(Collectors.toList());
}
// ページネーションサイズが偶数かどうか
boolean isEvenSize = paginationSize % 2 == 0;
int currentPageNumber = this.page.getNumber();
About to execute repetition 1 of 3 for RepeatedTestDemo#noArgs
About to execute repetition 2 of 3 for RepeatedTestDemo#noArgs
About to execute repetition 3 of 3 for RepeatedTestDemo#noArgs
About to execute repetition 1 of 1 for RepeatedTestDemo#customDisplayNameLongPattern
About to execute repetition 1 of 3 for RepeatedTestDemo#totalRepetitionsInfo
About to execute repetition 2 of 3 for RepeatedTestDemo#totalRepetitionsInfo
About to execute repetition 3 of 3 for RepeatedTestDemo#totalRepetitionsInfo
About to execute repetition 1 of 3 for RepeatedTestDemo#customDisplayName
About to execute repetition 2 of 3 for RepeatedTestDemo#customDisplayName
About to execute repetition 3 of 3 for RepeatedTestDemo#customDisplayName
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
class RepeatedTestDemo {
@BeforeEach
void beforeEach(TestInfo testInfo, RepetitionInfo repetitionInfo) {
// 現在の回数
int currentRepetition = repetitionInfo.getCurrentRepetition();