Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.rendering.test.integration;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.Suite;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.xwiki.component.manager.ComponentManager;
import org.xwiki.test.annotation.AllComponents;
import org.xwiki.test.annotation.ComponentList;
import org.xwiki.test.jmock.XWikiComponentInitializer;
import org.xwiki.test.mockito.MockitoComponentManager;
/**
* Run all tests found in {@code *.test} files located in the classpath. These {@code *.test} files must follow the
* conventions described in {@link org.xwiki.rendering.test.integration.TestDataParser}.
*
Usage Example
*
*
* {@literal @}RunWith(RenderingTestSuite.class)
* public class IntegrationTests
* {
* }
*
*
*
It's also possible to get access to the underlying Component Manager used, for example in order to register
* Mock implementations of components. For example:
*
*
* {@literal @}RunWith(RenderingTestSuite.class)
* {@literal @}AllComponents
* public class IntegrationTests
* {
* {@literal @}RenderingTestSuite.Initialized
* public void initialize(MockitoComponentManager componentManager)
* {
* // Init mocks here for example
* }
* }
*
*
*
* @version $Id: 206e9b41448f552920e2d95e86f91feef90319f0 $
* @since 3.0RC1
*/
public class RenderingTestSuite extends Suite
{
private static final TestDataGenerator GENERATOR = new TestDataGenerator();
private static final String DEFAULT_PATTERN = ".*\\.test";
private final Object klassInstance;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Initialized
{
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Scope
{
/**
* @return the classpath prefix to search in
*/
String value() default "";
/**
* @return the regex pattern to filter *.test files to execute
*/
String pattern() default DEFAULT_PATTERN;
}
private class TestClassRunnerForParameters extends
BlockJUnit4ClassRunner
{
private final int parameterSetNumber;
private final MockitoComponentManager mockitoComponentManager = new MockitoComponentManager();
private final XWikiComponentInitializer componentInitializer = new XWikiComponentInitializer();
private final List