use of org.whole.lang.tests.model.BeforeTest in project whole by wholeplatform.
the class BeforeTestPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
BeforeTest entity = getModelEntity();
List<IEntity> list = new ArrayList<IEntity>(3);
list.add(entity.getDescription());
list.add(entity.getName());
list.add(entity.getBody());
return list;
}
use of org.whole.lang.tests.model.BeforeTest in project whole by wholeplatform.
the class TestsInterpreterVisitor method visit.
@Override
public void visit(Test entity) {
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
getBindings().wEnterScope(ts);
String name = entity.getName().getValue();
Outcome outcome = TestsEntityFactory.instance.createOutcome(OutcomeEnum.SUCCESS);
StringLiteral location = CommonsEntityAdapterFactory.createResolver(StringLiteral);
StringLiteral cause = CommonsEntityAdapterFactory.createResolver(StringLiteral);
Result result = TestsEntityFactory.instance.createResult(outcome, location, cause);
try {
for (BeforeTest beforeTest : BehaviorUtils.<BeforeTest>compileAndLazyEvaluate(createAspectPath("BeforeTest"), entity)) {
beforeTest.accept(this);
getResult();
}
entity.getBody().accept(this);
getResult();
for (AfterTest afterTest : BehaviorUtils.<AfterTest>compileAndLazyEvaluate(createAspectPath("AfterTest"), entity)) {
afterTest.accept(this);
getResult();
}
printWriter().printf(" %32s(...) OK\n", name);
} catch (OperationCanceledException e) {
throw e;
} catch (TestsException e) {
outcome.wSetValue(OutcomeEnum.FAILURE);
location.setValue(EntityUtils.getLocation(e.getSubjectStatement()));
cause.setValue(e.getMessage());
reportFailure(name, e);
} catch (RuntimeException e) {
outcome.wSetValue(OutcomeEnum.ERROR);
IEntity sourceEntity = null;
if (e instanceof IWholeRuntimeException) {
sourceEntity = ((IWholeRuntimeException) e).getSourceEntity();
if (EntityUtils.getCompoundRoot(sourceEntity) != EntityUtils.getCompoundRoot(entity))
// FIXME replace with outer aspect or statement
sourceEntity = null;
}
if (sourceEntity == null)
sourceEntity = entity;
location.setValue(EntityUtils.getLocation(sourceEntity));
cause.setValue(e.getMessage());
reportError(name, e);
} finally {
ts.rollback();
getBindings().wExitScope();
}
if (EntityUtils.isResolver(entity.getExpectedResult()))
entity.setExpectedResult(EntityUtils.clone(result));
if (!Matcher.match(result, entity.getActualResult()))
entity.setActualResult(result);
setResult(result);
}
Aggregations