package geb.spock

import org.junit.rules.MethodRule
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.Statement

/**
 * Created by leo-13 on 11/11/2015.
 */
public class MethodExecutionRule implements MethodRule {

    public static failedTests = [] //list of failed tests

    public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
        return new Statement() {
            @Override
            public void evaluate() throws Throwable {
                try {
                    statement.evaluate()
                } catch (Throwable t) {
                    failedTests.add(frameworkMethod.getName()) //only adds failed tests
                    throw t
                }
            }
        }
    }
}
/* Copyright 2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package geb.spock

import org.junit.rules.MethodRule
import org.junit.runners.model.FrameworkMethod
import org.junit.runners.model.Statement

/**
 * Created by leo-13 on 11/11/2015.
 */
class MethodExecutionRule implements MethodRule {

    static failedTests = []

    Statement apply(Statement statement, FrameworkMethod frameworkMethod, Object o) {
        o.toString() // added to avoid codeNarc errors
        new Statement() {
            @Override
            void evaluate() throws Throwable {
                try {
                    statement.evaluate()
                } catch (Throwable t) {
                    failedTests.add(frameworkMethod.getName())
                    throw t
                }
            }
        }
    }
}
Fix code style issues according to codeNarc report
Fix code style issues according to codeNarc report
