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

[20210510] @ParameterizedTest, @ValueSource, logback #122

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

[20210510] @ParameterizedTest, @ValueSource, logback #122

JuHyun419 opened this issue May 10, 2021 · 0 comments

Comments

@JuHyun419
Copy link
Owner

JuHyun419 commented May 10, 2021

@ParameterizedTest, @valuesource

  • 테스트 코드에서 파라미터 설정할 수 있는 어노테이션
  • 아래 코드는 @valuesource 에 있는 int 배열(1, 3, 7, -3, 157, Integer.MAX_VALUE) 에 대해 매개변수로 테스트를 진행함
  • 6번의 테스트를 진행하며, 각 테스트마다 다른 값으로 진행
public class Number {
    public static boolean isOdd(final int number) {
        return number % 2 != 0;
    }
}

@ParameterizedTest
@ValueSource(ints = {1, 3, 7, -3, 157, Integer.MAX_VALUE}) // six numbers
void isOdd_ShouldReturnTrueForOddNumbers(int number) {
    assertTrue(Numbers.isOdd(number));
}

logback

  • 여러 Task의 클래스를 여러 files로 분리해서 로그 출력
  • appender 및 logger에 참조로 작성하면 각 Task에서 발생한 로그를 각 파일로 출력 가능
    <appender name="DEL_DATA" class="ch.qos.logback.core.FileAppender">
    	<file>${log.dir}/${log.filename}-DelData.log</file>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date{MM-dd HH:mm:ss.SSS} %-10.10thread %-5level %logger{35} %5line %msg%n</pattern>
        </layout>
    	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.dir}/${log.filename}-DelData.%d{yyyy-MM-dd}.log</fileNamePattern>
        </rollingPolicy>
    </appender>
    
        <appender name="DEL_PERSONAL" class="ch.qos.logback.core.FileAppender">
    	<file>${log.dir}/${log.filename}-DelPersonal.log</file>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%date{MM-dd HH:mm:ss.SSS} %-10.10thread %-5level %logger{35} %5line %msg%n</pattern>
        </layout>
    	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${log.dir}/${log.filename}-DelPersonal.%d{yyyy-MM-dd}.log</fileNamePattern>
        </rollingPolicy>
    </appender>

    <logger name="com.test.batch.task.DelTask" level="INFO" additivity="false">
    	<appender-ref ref="DEL_DATA" />
    </logger>
    
    <logger name="com.test.batch.task.DelPersonTask" level="INFO" additivity="false">
    	<appender-ref ref="DEL_PERSONAL" />
    </logger>
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