Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20210511] @ParameterizedTest, @CsvSource, @ValueSource #123

Open
JuHyun419 opened this issue May 11, 2021 · 0 comments
Open

[20210511] @ParameterizedTest, @CsvSource, @ValueSource #123

JuHyun419 opened this issue May 11, 2021 · 0 comments

Comments

@JuHyun419
Copy link
Owner

@ParameterizedTest,

  • 파라미터에 대해 여러번 던져서 테스트를 수행할 수 있는 어노테이션
  • 반드시! 파라미터를 넘겨야 하며, @valuesource 또는 @CsvSourec 어노테이션 등과 함께 파라미터를 던져주어야 함

@CsvSource

  • CsvSource 어노테이션의 value 속성으로 다음과 같이 파라미터를 던질 수 있음
    • @CsvSource({"1, '자바 스터디', '2021-05-11T22:30:36', true", "2, '스프링 스터디', '2021-05-12T22:30:36', false"})
  • 위 예제처럼 콤마(,)를 기준으로 문자열의 값을 짤라서 파라미터에 담는다.

@valuesource

  • 여러번의 파라미터를 던질 수 있도록 하는 어노테이션중 하나이다.
  • 단 하나의 타입만 던질 수 있음
    • @valuesource(ints = {10, 20, 30}) ==> 단 하나의 타입
    • @valuesource(ints = {10, 20, 30}, strings = {"문자1", "문자2", "문자3") ==> 두 가지 타입(불가능)
  • 두 번째 예제는 int, String 의 두 타입을 던지므로 불가능!

image

https://sas-study.tistory.com/320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant