Clear Properties

ClearSystemProperties在测试之前删除资源文件,测试结束之后恢复

    package com.junit.learning.systemtest;

    import org.junit.Rule;
    import org.junit.Test;
    import org.junit.contrib.java.lang.system.ClearSystemProperties;

    import static org.assertj.core.api.Assertions.assertThat;

    public class ClearProperties {
        @Rule
        public final ClearSystemProperties myPropertyIsCleared = new ClearSystemProperties("MyProperty");

        @Test
        public void overrideProperty() {
            assertThat(System.getProperty("MyProperty")).isNull();
        }
    }
Copyright © www.gitbook.com/@herryZ 2016 all right reserved,powered by Gitbook该文件修订时间: 2017-03-13 05:37:11

results matching ""

    No results matching ""