1 package org.apache.archiva.web.test.tools;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.web.test.parent.AbstractSeleniumTest;
22 import org.junit.rules.MethodRule;
23 import org.junit.runner.Description;
24 import org.junit.runners.model.FrameworkMethod;
25 import org.junit.runners.model.Statement;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 * @author Olivier Lamy
32 public class ArchivaSeleniumExecutionRule
33 implements MethodRule //TestRule
36 final Logger log = LoggerFactory.getLogger( ArchivaSeleniumExecutionRule.class );
39 public Statement apply( Statement base, FrameworkMethod method, Object target )
43 log.info("Test "+method.getDeclaringClass().getName()+"#"+method.getName());
44 ( (AbstractSeleniumTest) target ).open();
45 method.getMethod().invoke( target );
50 log.info("Exception thrown in Selenium test: "+e.getClass().getName()+" - "+e.getMessage());
51 log.info("Method "+method.getName());
53 ( (AbstractSeleniumTest) target ).captureScreenShotOnFailure( e, method.getMethod().getName(),
54 target.getClass().getName() );
56 throw new RuntimeException( e.getMessage() + " see screenShot file:" + fileName, e );
60 ( (AbstractSeleniumTest) target ).close();
63 return new Statement()
66 public void evaluate()
74 public Statement apply( Statement base, Description description )