All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.polonium.core.TransactionalSpringDescriptionBuilder Maven / Gradle / Ivy

package com.polonium.core;

/** Integration idea - try of making AbstractTransactionalJUnitTests part of PoloniumTests
 * @author Marek Serwanski
 *
 */
public class TransactionalSpringDescriptionBuilder {
//	private Description classDescription;
//	private int testCounter = 0;
//	
//	public Description getClassDescription() {
//		return classDescription;
//	}
//	
//	/** Returns root description of selected index of test (from all tests description)
//	 * @param index
//	 * @return
//	 */
//	public Description getTestRootDescription(int index){
//		return classDescription.getChildren().get(index);
//	}
//	
//	/** Recognizes if detailed description schould be build. Try to read from: 
// * system property or annotation @DetailedDescription present // */ // public void getDetailedDescriptionType(TestClass testClass) { // String property = System.getProperty(DETAILED_DESCRIPTION_PROP_NAME); // if ((property != null) && !property.equals(Boolean.FALSE.toString())) { // DETAILED_DESCRIPTION = true; // } // // if(!testClass.getAnnotatedFieldValues(testClass, DetailedDescription.class, String.class).isEmpty()){ // DETAILED_DESCRIPTION = true; // } // } // // /** creates full description of all test methods based on annotations Given, When, Then // * @param testClass // */ // public void createDescription(TestClass testClass, List tests) { // classDescription = Description.createSuiteDescription(testClass.getName()); // // for (FrameworkMethod test : tests) { // if(!isTestProperlyAnnotated(test)){ // throw new AnnotationException(test.getName() + " is not properly annotaded with @Given @When @Then"); // } // if(!DETAILED_DESCRIPTION) createOneDescriptionFromAnnotations(test); // else{ // Description testDescription = Description.createSuiteDescription(test.getName()); // classDescription.addChild(testDescription); // // testCounter++; // createDescriptionsFromAnnotations(testClass, test, testDescription); // } // } // } // // /** If test is annotated with all mandatory annotations */ // public boolean isTestProperlyAnnotated(FrameworkMethod method) { // return (method.getAnnotation(Given.class) != null && // method.getAnnotation(When.class)!= null && // method.getAnnotation(Then.class) != null); // } // // private void createDescriptionsFromAnnotations(TestClass testClass, FrameworkMethod test, Description testDescription) { // String testNumber = getTestNumber(); // // testDescription.addChild(Description.createTestDescription(testClass.getClass(), // GIVEN_PREFIX + getGivenDescription(test) + testNumber)); // testDescription.addChild(Description.createTestDescription(testClass.getClass(), // WHEN_PREFIX + getWhenDescription(test) + testNumber)); // testDescription.addChild(Description.createTestDescription(testClass.getClass(), // THEN_PREFIX + getThenDescription(test) + testNumber)); // } // // private void createOneDescriptionFromAnnotations(FrameworkMethod test) { // String descriptionValue = ( // test.getName() + // getTestNumber() + // GIVEN_PREFIX + getGivenDescription(test) + SEPARATOR + // WHEN_PREFIX + getWhenDescription(test) + SEPARATOR + // THEN_PREFIX + getThenDescription(test) // ); // // Description testDescription = Description.createSuiteDescription(descriptionValue); // classDescription.addChild(testDescription); // } // // private String getTestNumber(){ // return " {" + testCounter + "} "; // } // // private String getGivenDescription(FrameworkMethod test){ // return test.getAnnotation(Given.class).value(); // } // // private String getWhenDescription(FrameworkMethod test){ // return test.getAnnotation(When.class).value(); // } // // private String getThenDescription(FrameworkMethod test){ // return test.getAnnotation(Then.class).value(); // } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy