- 우리는 가장 의미있는 테스트(general case)를 제일 먼저 떠올린다.
- 하지만 그런 테스트는 구현이 복잡하고, 그런 기능을 제일 먼저 구현하면 예외적인 경우들이 누락되는 현상이 발생하기 쉽다.
- tdd에서는 functional decomposition을 통해서 가장 단순한 테스트(special case)부터 추가해 가면서 최종적으로 general case에 도달하기 위한 stair step tests 목록을 작성하게 됨
- 절차
- most simple and degenerate(special)에서 시작
- null, empty, 0, boundary, simple stuff 등과 같은 special case
- most simple and degenerate(special)에서 시작
- 다음 단계로 interesting 하지만 조금 덜 degenerate한 테스트 케이스(단일
This file contains hidden or 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
public class Divider { | |
public int divide(int dividend, int divisor) { | |
if (divisor == null) { | |
throw new IllegalArgumentException("divisor must not be null"); | |
} | |
if (dividend == null) { | |
throw new IllegalArgumentException("dividend must not be null"); | |
} | |
if (divisor == 0) { | |
throw new IllegalArgumentException("divisor must not be 0"); |
This file contains hidden or 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
public class Divider { | |
public int divide(int dividend, int divisor) { | |
if (divisor != null) { | |
if(dividend != null) { | |
if (divisor != 0) { | |
return dividend / divisor; | |
} else { | |
throw new IllegalArgumentException("divisor must not be 0"); | |
} | |
} else { |
This file contains hidden or 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
public class Divider { | |
public int divide(int dividend, int divisor) { | |
return dividend / divisor; | |
} | |
} |
This file contains hidden or 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
import { calc, search } from '@/pages/goodsList/search'; | |
describe('search api', () => { | |
it('search api를 호출한다.', async () => { | |
const { data } = await search({ keyword: 'blackpink' }); | |
// console.log(data); | |
expect(data).toMatchSnapshot(); | |
}); | |
}); |
This file contains hidden or 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
@Configuration | |
class CorsConfiguration { | |
@Bean | |
WebMvcConfigurer corsConfigurer() { | |
return new WebMvcConfigurer() { | |
@Override | |
public void addCorsMappings(final CorsRegistry registry) { | |
registry.addMapping("/**") | |
.allowedHeaders("*") | |
.allowedMethods("*") |
This file contains hidden or 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
@Test | |
void queryDslQueryTest() { | |
JPAQuery<StatusCommonTemplateExcelData> query = | |
jpaQueryFactory.select( | |
Projections.constructor( | |
StatusCommonTemplateExcelData.class, | |
Expressions.stringTemplate("'집품'"), | |
qWarehouse.name, // "창고" | |
qPacking.status, // "포장 상태" | |
qShipping.deliverySeq, // "배송 ID" |
This file contains hidden or 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
// mapstruct | |
annotationProcessor "org.mapstruct:mapstruct-processor:$mapstructVersion" | |
implementation "org.mapstruct:mapstruct:$mapstructVersion" | |
[For Java Developers: Forget BeanUtils and Trade for Performance and Code Simplicity by MapStruct | by Malvin Lok | Feb, 2024 | Medium](https://medium.com/@malvin.lok/for-java-developers-forget-beanutils-and-trade-for-performance-and-code-simplicity-by-mapstruct-b8934c830094) | |
@Data | |
@Builder | |
@AllArgsConstructor |
This file contains hidden or 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
// loading load runner | |
@Bean | |
public ApplicationRunner runner(BalanceRepository balanceRepository) { | |
return args -> { | |
// ... | |
}; | |
} | |
@Component | |
public class DataLoader implements CommandLineRunner { |
This file contains hidden or 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
pom.xml | |
<!-- Encryption Library --> | |
<dependency> | |
<groupId>com.github.ulisesbocchio</groupId> | |
<artifactId>jasypt-spring-boot-starter</artifactId> | |
<version>3.0.2</version> | |
</dependency> | |
<dependency> | |
<groupId>org.bouncycastle</groupId> | |
<artifactId>bcprov-jdk15on</artifactId> |
NewerOlder