Skip to content

Commit

Permalink
fix(#1014): Use testcase runner provider everywhere
Browse files Browse the repository at this point in the history
Also fix license headers for new files
  • Loading branch information
christophd committed Oct 20, 2023
1 parent c56347f commit fac8c04
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.citrusframework;

import org.citrusframework.context.TestContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright 2023 the original author or authors.
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.citrusframework;

import org.citrusframework.context.TestContext;
Expand Down Expand Up @@ -61,7 +80,6 @@ private TestCaseRunnerProvider lookupCustomOrDefault() {
}
}


/**
* Create a runner.
* @param context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
package org.citrusframework;
/*
* Copyright 2023 the original author or authors.
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
package org.citrusframework;

import org.citrusframework.context.TestContext;
import org.citrusframework.spi.ResourcePathTypeResolver;
Expand All @@ -10,6 +26,9 @@
import org.testng.Assert;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class TestCaseRunnerFactoryTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import java.util.Map;
import java.util.Optional;

import io.cucumber.core.backend.ObjectFactory;
import io.cucumber.core.exception.CucumberException;
import org.citrusframework.CitrusInstanceManager;
import org.citrusframework.DefaultTestCaseRunner;
import org.citrusframework.TestCaseRunner;
import org.citrusframework.TestCaseRunnerFactory;
import org.citrusframework.annotations.CitrusAnnotations;
import org.citrusframework.context.TestContext;
import io.cucumber.core.backend.ObjectFactory;
import io.cucumber.core.exception.CucumberException;

/**
* @author Christoph Deppisch
Expand Down Expand Up @@ -57,7 +57,7 @@ public CitrusObjectFactory() {
@Override
public void start() {
context = CitrusInstanceManager.getOrDefault().getCitrusContext().createTestContext();
runner = new DefaultTestCaseRunner(context);
runner = TestCaseRunnerFactory.createRunner(context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

package org.citrusframework.cucumber.backend.spring;

import io.cucumber.core.backend.CucumberBackendException;
import io.cucumber.core.backend.ObjectFactory;
import io.cucumber.spring.SpringFactory;
import org.citrusframework.Citrus;
import org.citrusframework.CitrusContext;
import org.citrusframework.CitrusInstanceManager;
import org.citrusframework.CitrusSpringContext;
import org.citrusframework.CitrusSpringContextProvider;
import org.citrusframework.DefaultTestCaseRunner;
import org.citrusframework.TestCaseRunner;
import org.citrusframework.TestCaseRunnerFactory;
import org.citrusframework.annotations.CitrusAnnotations;
import org.citrusframework.context.TestContext;
import org.citrusframework.context.TestContextFactoryBean;
import io.cucumber.core.backend.CucumberBackendException;
import io.cucumber.core.backend.ObjectFactory;
import io.cucumber.spring.SpringFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
Expand Down Expand Up @@ -65,7 +65,7 @@ public CitrusSpringObjectFactory() {
public void start() {
delegate.start();
context = getInstance(TestContext.class);
runner = new DefaultTestCaseRunner(context);
runner = TestCaseRunnerFactory.createRunner(context);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

import org.citrusframework.CitrusSettings;
import org.citrusframework.DefaultTestCase;
import org.citrusframework.DefaultTestCaseRunner;
import org.citrusframework.TestCaseRunner;
import org.citrusframework.TestCaseRunnerFactory;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.spi.ClasspathResourceResolver;
Expand Down Expand Up @@ -73,7 +73,7 @@ public static void invokeTestMethod(Object target, CitrusFrameworkMethod framewo
* @return
*/
public static TestCaseRunner createTestRunner(CitrusFrameworkMethod frameworkMethod, Class<?> testClass, TestContext context) {
TestCaseRunner testCaseRunner = new DefaultTestCaseRunner(new DefaultTestCase(), context);
TestCaseRunner testCaseRunner = TestCaseRunnerFactory.createRunner(new DefaultTestCase(), context);
testCaseRunner.testClass(testClass);
testCaseRunner.name(frameworkMethod.getTestName());
testCaseRunner.packageName(frameworkMethod.getPackageName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.citrusframework.Citrus;
import org.citrusframework.CitrusInstanceManager;
import org.citrusframework.DefaultTestCaseRunner;
import org.citrusframework.GherkinTestActionRunner;
import org.citrusframework.TestActionRunner;
import org.citrusframework.TestCaseRunner;
import org.citrusframework.TestCaseRunnerFactory;
import org.citrusframework.annotations.CitrusAnnotations;
import org.citrusframework.annotations.CitrusFramework;
import org.citrusframework.annotations.CitrusResource;
Expand Down Expand Up @@ -77,7 +77,7 @@ public void inject(Object testInstance) {
}

context = citrus.getCitrusContext().createTestContext();
runner = new DefaultTestCaseRunner(context);
runner = TestCaseRunnerFactory.createRunner(context);
runner.testClass(testInstance.getClass());
runner.packageName(testInstance.getClass().getPackageName());
runner.name(testInstance.getClass().getSimpleName());
Expand Down

0 comments on commit fac8c04

Please sign in to comment.