Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Create a TPTP Manual Test Suite

Purpose

Programmatically creates a TPTP Manual Test Suite with one test case and its invocation.

Requires

  • org.eclipse.tptp.platform.models
  • org.eclipse.tptp.test.tools.manual

Imports

  • org.eclipse.emf.common.util.URI
  • org.eclipse.emf.ecore.resource.Resource
  • org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
  • org.eclipse.hyades.loaders.util.Guid
  • org.eclipse.hyades.models.common.facades.behavioral.IImplementor
  • org.eclipse.hyades.models.common.facades.behavioral.ITestCase
  • org.eclipse.hyades.models.common.facades.behavioral.ITestInvocation
  • org.eclipse.hyades.models.common.facades.behavioral.ITestSuite
  • org.eclipse.hyades.models.common.facades.behavioral.impl.FacadeResourceFactoryImpl
  • org.eclipse.hyades.models.common.facades.behavioral.impl.HyadesFactory
  • org.eclipse.tptp.test.tools.manual.util.ManualConstants

Inputs

  • testSuitePath: The name and absolute path of the TPTP Manual Test Suite.

Source Code


//Initialize test models:
FacadeResourceFactoryImpl.initializeRequisiteModels();

//Create the test suite resource:
Resource resource = new ResourceSetImpl().createResource(URI.createFileURI(testSuitePath));
//Create the test suite:
ITestSuite testSuite = HyadesFactory.INSTANCE.createTestSuite(resource);
testSuite.setId(Guid.generate());
testSuite.setType(ManualConstants.MANUAL_TEST_SUITE_TYPE);
testSuite.setName("sampleManualTestSuite");
testSuite.setDescription("TPTP sample manual test suite.");

//Create the test suite implementor:
IImplementor testSuiteImplementor = HyadesFactory.INSTANCE.createImplementor(testSuite, false);
testSuiteImplementor.setId(Guid.generate());
		
//Create the test case:
ITestCase testCase = HyadesFactory.INSTANCE.createTestCase();
testCase.setId(Guid.generate());
testCase.setType(ManualConstants.MANUAL_TEST_CASE_TYPE);
testCase.setName("sampleManualTestCase");
testCase.setDescription("TPTP sample manual test case.");

//Add the test case to the test suite BEFORE adding the implementor to the test:
testSuite.getITestCases().add(testCase);

//Create and add the test case implementor:
IImplementor testCaseImplementor = HyadesFactory.INSTANCE.createImplementor(testCase, false);
testCaseImplementor.setId(Guid.generate());
testCaseImplementor.setName("test " + (testSuite.getITestCases().size()) + "_behavior");
testCaseImplementor.setResource("sampleManualTestCase");

//Create and add the test case invocation:
ITestInvocation testInvocation = HyadesFactory.INSTANCE.createTestInvocation(testCase);
testInvocation.setId(Guid.generate());
testInvocation.setName("sampleManualTestCase - invocation");
testInvocation.setDescription("TPTP sample manual test case invocation.");

//Add the test case invocation to the test suite:
testSuite.getImplementor().getBlock().getActions().add(testInvocation);

//Save the test suite:
resource.save(Collections.EMPTY_MAP);

Back to the top