Skip to content

Instantly share code, notes, and snippets.

View b1a9id's full-sized avatar
🍻

Ryosuke Uchitate b1a9id

🍻
View GitHub Profile
@b1a9id
b1a9id / pom.xml
Created October 19, 2017 01:56
SBのAssertJバージョン指定
<properties>
<assertj.version>3.8.0</assertj.version>
</properties>
/**
* brandsの中で、nameに「e」を含んでいるものを抽出
*/
@Test
public void filteringPredicate() {
Brand stof = new Brand("stof", "Tanita", Gender.MAN);
Brand bedsidedrama = new Brand("bedsidedrama", "Tanita", Gender.MAN);
Brand sneeuw = new Brand("sneeuw", "Yukiura", Gender.WOMAN);
Brand ethosens = new Brand("ETHOSENS", "Hashimoto", Gender.MAN);
Brand dulcamara = new Brand("Dulcamara", "Yoda", Gender.WOMAN);
@b1a9id
b1a9id / Brand.java
Created November 25, 2017 08:24
テスト対象クラス
package com.example.assertjsandbox.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@b1a9id
b1a9id / pom.xml
Last active December 26, 2017 01:56
JUnit5
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
@b1a9id
b1a9id / StandardTest.java
Last active December 27, 2017 01:29
スタンダードテスト
import org.junit.jupiter.api.*;
@DisplayName("This is standard test.")
class StandardTest {
@BeforeAll
static void beforeAll() {
System.out.println("executed before all test just once.");
}
@b1a9id
b1a9id / StandardAsserrionTest.java
Last active December 27, 2017 01:32
基本的なアサーション
import com.example.core.model.*;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.*;
class StandardAssertionTest {
@Nested
class DependentAssertions {
executed before all test just once.
executed before each test.
This is test1.
This is Disabled test.
executed before each test.
This is test3.
org.opentest4j.MultipleFailuresError: This is name test. (1 failure)
expected: <Ryo> but was: <Ryosuke>
org.opentest4j.TestAbortedException: Assumption failed: This is invalid.
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();