
com.ecfeed.core.provider.TCProviderGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecfeed.junit Show documentation
Show all versions of ecfeed.junit Show documentation
An open library used to connect to the ecFeed service. It can be also used as a standalone testing tool. It is integrated with Junit5 and generates a stream of test cases using a selected algorithm (e.g. Cartesian, N-Wise). There are no limitations associated with the off-line version but the user cannot access the on-line computation servers and the model database.
The newest version!
/*******************************************************************************
*
* Copyright (c) 2016 ecFeed AS.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package com.ecfeed.core.provider;
import java.util.List;
import com.ecfeed.core.generators.api.GeneratorException;
import com.ecfeed.core.generators.api.IGenerator;
import com.ecfeed.core.model.ChoiceNode;
import com.ecfeed.core.model.MethodNode;
import com.ecfeed.core.model.TestCaseNode;
import com.ecfeed.core.utils.ExceptionHelper;
import com.ecfeed.core.utils.IEcfProgressMonitor;
public class TCProviderGenerator implements ITCProvider {
private MethodNode fMethodNode;
private IGenerator fGenerator;
private IEcfProgressMonitor fProgressMonitor;
public TCProviderGenerator(MethodNode methodNode, IGenerator generator) {
fMethodNode = methodNode;
fGenerator = generator;
}
@Override
public void initialize(ITCProviderInitData initData, IEcfProgressMonitor progressMonitor) {
fProgressMonitor = progressMonitor;
TCProviderGenInitData genInitData = (TCProviderGenInitData) initData;
initializeGenerator(progressMonitor, genInitData);
}
private void initializeGenerator(IEcfProgressMonitor progressMonitor, TCProviderGenInitData genInitData) {
try {
fGenerator.initialize(
genInitData.getChoiceInput(),
genInitData.getConstraints(),
genInitData.getGeneratorArguments(),
progressMonitor);
} catch (GeneratorException e) {
ExceptionHelper.reportRuntimeException("Cannot initalize generator.", e);
}
}
@Override
public void close() {
}
@Override
public MethodNode getMethodNode() {
return fMethodNode;
}
@Override
public TestCaseNode getNextTestCase() {
List choices = getNext();
if (choices == null) {
if (fProgressMonitor != null) {
fProgressMonitor.setTaskEnd();
}
return null;
}
return new TestCaseNode("", null, choices);
}
private List getNext() {
try {
return fGenerator.next();
} catch (GeneratorException e) {
ExceptionHelper.reportRuntimeException("Cannot get next test case.", e);
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy