BaseTest.java

package com.ruoyi.base;

import com.ruoyi.RuoYiApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Optional;

/**
 * @author Kelvin范显
 * @createDate 2019年03月25日
 */

@RunWith(SpringRunner.class)
@SpringBootTest(classes={RuoYiApplication.class})// 指定启动类
public class BaseTest {

    /**
     * -------------------
     * 
     * test print
     * 
     * -------------------
     * @param info
     */
    public void print(Object info) {
        StackTraceElement[] stacks = (new Throwable()).getStackTrace();
        StackTraceElement stack = Optional.ofNullable(stacks[1]).orElse(stacks[0]);
        System.out.println("\n-------------------\n"
            +"<"+stack.getClassName() + "#" + stack.getMethodName()+">\n"
            +info.toString()+"\n"
            +"\n"
            +"-------------------\n");
    }


    public static void main(String[] args) {
        new BaseTest().print("test print");
    }
}

你可能感兴趣的:(BaseTest.java)