001/* 002 * Copyright 2018 Nils Hoffmann <nils.hoffmann@isas.de>. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.isas.mztab2.test.utils; 017 018import org.junit.rules.TestWatcher; 019import org.junit.runner.Description; 020 021/** 022 * JUnit TestWatcher to LOGGER the executed test method name. 023 * 024 * @author nilshoffmann 025 */ 026public class LogMethodName extends TestWatcher { 027 028 /** 029 * Called when JUnit is about to execute the provided method. 030 * 031 * @param method the method being executed by JUnit. 032 */ 033 @Override 034 public void starting(Description method) { 035 StringBuilder sb = new StringBuilder(); 036 for (int i = 0; i < 80; i++) { 037 sb.append("#"); 038 } 039 sb.append("\n"). 040 append("# "). 041 append(method.getMethodName()). 042 append("\n"); 043 for (int i = 0; i < 80; i++) { 044 sb.append("#"); 045 } 046 System.out.println(sb.toString()); 047 } 048 049}