How to use Annotation Type Categories.ExcludeCategory class of org.junit.experimental.categories package

Best junit code snippet using org.junit.experimental.categories.Annotation Type Categories.ExcludeCategory

Source:ClassRecords.java Github

copy

Full Screen

1/**2 *3 * @ProjectName JunitTestWithActualLib4 *5 * @PackageName tools.code.gen6 *7 * @FileName ClassRecords.java8 * 9 * @FileCreated Jan 02, 201310 *11 * @Author MD. SHOHEL SHAMIM12 *13 * @CivicRegistration 19841201-053314 *15 * MSc. in Software Technology16 *17 * Linnaeus University, Växjö, Sweden18 *19 */20package tools.code.gen;21import java.lang.annotation.Annotation;22import java.lang.reflect.Constructor;23import java.util.ArrayList;24import java.util.Collection;25import java.util.HashMap;26import java.util.List;27import org.junit.experimental.categories.Categories.ExcludeCategory;28import org.junit.experimental.categories.Categories.IncludeCategory;29import org.junit.runner.RunWith;30import org.junit.runners.Suite.SuiteClasses;31/**32 * <li><strong>ClassRecords</strong></li>33 * 34 * <pre>35 * public class ClassRecords <blockquote>implements</blockquote> AnnotaionList36 * </pre>37 * <p>38 * This class contains information of classes by exploring class annotations and39 * other properties. It keeps information of only entry class. A <b>entry40 * class</b> is a class where test begins. If a class has SuiteClasses then each41 * class will create new instance of ClassRecords (This class). Because, classes42 * those are in SuiteClasses runs as a separate test class.43 * </p>44 * <br/>45 * 46 * @author Shohel Shamim47 */48public class ClassRecords implements AnnotaionList {49 /* Keep annotations of a class. Key: Annotation, Value: annotation name */50 private HashMap<Annotation, String> annotations;51 /* Keep each entry class. */52 private Class<?> claz;53 /*54 * If a class has constructor then it keep constructor's parameters type as55 * String (parameter name).56 */57 private Object[] constructorsParametsType;58 /*59 * If a class has constructor then it keep constructor's parameters type60 * CLASS.61 */62 private Class<?>[] constructorsParametsTypeClass;63 /*64 * If class has @ExcludeCategory annotation then it will keep those65 * information.66 */67 private List<Class<?>> excludeCategory;68 /* True is class has annotation @RunWith(Categories.class) */69 private boolean hasRunWithCategories;70 /*71 * True if annotation @RunWith(Categories.class) found in any level of72 * ClassRecords. See hasRunWithCategoriesAtItsPath() for details73 * information.74 */75 private boolean hasRunWithCategoriesAtItsPath;76 /* True is class has annotation @RunWith(Parameterized.class) */77 private boolean hasRunWithParameterized;78 /* True is class has annotation @RunWith(Suite.class) */79 private boolean hasRunWithSuite;80 /* True is class has annotation @RunWith(Theories.class) */81 private boolean hasRunWithTheories;82 /* True is class has annotation @RunWith(Suite.class) */83 private boolean hasSuiteClasses;84 /*85 * If class has @IncludeCategory annotation then it will keep those86 * information.87 */88 private List<Class<?>> includeCategory;89 /*90 * If a class has @Ignore then it will be true. Initially it's false.91 */92 private boolean isIgnored = false;93 private Collection<?> parametersData;94 /*95 * If class has SuiteClasses then each ClassRecords contains one or multiple96 * ClassRecords. This field contains the parent of ClassRecords object.97 */98 private ClassRecords parentClassRecord;99 /*100 * If class has SuiteClasses then this field contains list of classes.101 */102 private List<ClassRecords> suiteClasses;103 /**104 * <li><strong><i>ClassRecords</i></strong></li>105 * 106 * <pre>107 * public ClassRecords(Class<?> currentClass)108 * </pre>109 * 110 * <p>111 * Take only entry class as parameter that is the starting point of a test112 * class. Do not pass any other classes. If there are SuiteClasses it will113 * find them and create new object of ClassRecords by itself. Example: If114 * ClassA has to test, then create new object of ClassRecords as<br/>115 * <code>ClassRecords cr = new ClassRecords(ClassA.class);</code>116 * </p>117 * 118 * @param currentClass119 * - a class name with .class extension or Class Type120 * 121 * 122 * @author Shohel Shamim123 */124 public ClassRecords(Class<?> currentClass) {125 this(currentClass, null);126 }127 /**128 * <li><strong><i>ClassRecords</i></strong></li>129 * 130 * <pre>131 * private ClassRecords(Class<?> current, ClassRecords parentClassRecord)132 * </pre>133 * 134 * <p>135 * This constructor is used as an extension of <code>public136 * ClassRecords(Class<?> currentClass)</code>. If entry class has Suite137 * Classes (in simple word, multiple entry classes) then it will be used to138 * keep the parent ClassRecords.139 * </p>140 * 141 * @param currentClass142 * - a class name with .class extension or Class Type143 * @param parentClassRecord144 * - a parent ClassRecords145 * 146 * 147 * @author Shohel Shamim148 */149 private ClassRecords(Class<?> current, ClassRecords parentClassRecord) {150 this.claz = current;151 this.parentClassRecord = parentClassRecord;152 this.parametersData = null;153 this.suiteClasses = new ArrayList<ClassRecords>();154 this.annotations = new HashMap<Annotation, String>();155 // If there are Categories then156 // copyIncludeOrExcludeCategoriesFromParent() will store them in157 // includeCategory and excludeCategory list. Do not change the position158 // to run the system successfully.159 copyIncludeOrExcludeCategoriesFromParent();160 readAnnotations(this.claz);161 }162 /**163 * <li><strong><i>addExcludeCategoryClass</i></strong></li>164 * 165 * <pre>166 * private void addExcludeCategoryClass(Class<?> clz)167 * </pre>168 * 169 * <p>170 * Add class those are inside in ExcludeCategory as a marker.171 * </p>172 * 173 * @param clz174 * - a class name with .class extension or Class Type175 * 176 * @author Shohel Shamim177 */178 private void addExcludeCategoryClass(Class<?> clz) {179 if (!(this.excludeCategory.contains(clz))) {180 this.excludeCategory.add(clz);181 }182 }183 /**184 * <li><strong><i>addIncludeCategoryClass</i></strong></li>185 * 186 * <pre>187 * private void addIncludeCategoryClass(Class<?> clz)188 * </pre>189 * 190 * <p>191 * Add class those are inside in IncludeCategory as a marker.192 * </p>193 * 194 * @param clz195 * - a class name with .class extension or Class Type196 * 197 * @author Shohel Shamim198 */199 private void addIncludeCategoryClass(Class<?> clz) {200 if (!(this.includeCategory.contains(clz))) {201 this.includeCategory.add(clz);202 }203 }204 /**205 * <li><strong><i>copyIncludeOrExcludeCategoriesFromParent</i></strong></li>206 * 207 * <pre>208 * private void copyIncludeOrExcludeCategoriesFromParent()209 * </pre>210 * 211 * <p>212 * Keep new copy of Include and Exclude category data.213 * </p>214 * 215 * @author Shohel Shamim216 */217 private void copyIncludeOrExcludeCategoriesFromParent() {218 if (this.parentClassRecord != null) {219 // Creating a shallow copy220 this.includeCategory = new ArrayList<Class<?>>(221 this.parentClassRecord.getIncludeCategoryClass());222 this.excludeCategory = new ArrayList<Class<?>>(223 this.parentClassRecord.getExcludeCategoryClass());224 } else {225 this.includeCategory = new ArrayList<Class<?>>();226 this.excludeCategory = new ArrayList<Class<?>>();227 }228 }229 /**230 * <li><strong><i>getAnnotations</i></strong></li>231 * 232 * <pre>233 * public HashMap<Annotation, String> getAnnotations()234 * </pre>235 * 236 * <p>237 * Return annotations HashMap of current class. HashMap - Key: Annotation238 * and Value: annotation Name.239 * </p>240 * 241 * @return HashMap - return Annotation List242 * 243 * @author Shohel Shamim244 */245 public HashMap<Annotation, String> getAnnotations() {246 return this.annotations;247 }248 /**249 * <li><strong><i>readAnnotations</i></strong></li>250 * 251 * <pre>252 * private void readAnnotations(Class<?> cls)253 * </pre>254 * 255 * <p>256 * Retrieve annotations of classes and keep them in the right property.257 * Depending on Annotation different property was set. This method is very258 * important to generate code.259 * </p>260 * 261 * @param cls262 * - a class name with .class extension or Class Type263 * 264 * @author Shohel Shamim265 */266 private void readAnnotations(Class<?> cls) {267 Class<?>[] suits = null;268 Class<?> inCategory = null;269 Class<?> exCategory = null;270 // reset value of essential properties of class271 resetValues();272 // Setting properties and collecting list of @Suite classes273 for (Annotation annotation : cls.getAnnotations()) {274 String name = annotation.annotationType().getSimpleName();275 this.annotations.put(annotation, name);276 if (name.equalsIgnoreCase(Ignore)) {277 this.isIgnored = true;278 } else if (name.equalsIgnoreCase(RunWith)) {279 RunWith runWith = (RunWith) annotation;280 if (runWith.value().getSimpleName().equalsIgnoreCase(Suite)) {281 this.hasRunWithSuite = true;282 } else if (runWith.value().getSimpleName()283 .equalsIgnoreCase(Categories)) {284 this.hasRunWithCategories = true;285 } else if (runWith.value().getSimpleName()286 .equalsIgnoreCase(Theories)) {287 this.hasRunWithTheories = true;288 } else if (runWith.value().getSimpleName()289 .equalsIgnoreCase(Parameterized)) {290 this.hasRunWithParameterized = true;291 }292 } else if (name.equalsIgnoreCase(IncludeCategory)) {293 inCategory = ((IncludeCategory) annotation).value();294 } else if (name.equalsIgnoreCase(ExcludeCategory)) {295 exCategory = ((ExcludeCategory) annotation).value();296 } else if (name.equalsIgnoreCase(SuiteClasses)) {297 // Adding classes those are in @Suite.SuiteClasses{};298 // class will be store as a object of ClassRecords later299 suits = ((SuiteClasses) annotation).value();300 this.hasSuiteClasses = true;301 }302 }303 if (hasRunWithCategories()) {304 this.hasRunWithCategoriesAtItsPath = true;305 } else {306 if (this.parentClassRecord != null307 && this.parentClassRecord.hasRunWithCategoriesAtItsPath()) {308 this.hasRunWithCategoriesAtItsPath = true;309 }310 }311 // If parent class is ignored then other essential properties won't312 // work; so must need to reset them313 if (this.isIgnored) {314 resetValues();315 } else if (this.hasRunWithParameterized) {316 Constructor<?>[] constructors = cls.getDeclaredConstructors();317 // Parameterized class have only one constructor, not more or less,318 // so, it can call first element from the array319 Constructor<?> constructor = constructors[0];320 this.constructorsParametsType = new Object[constructor321 .getParameterTypes().length];322 this.constructorsParametsTypeClass = new Class<?>[constructor323 .getParameterTypes().length];324 for (int i = 0; i < constructor.getParameterTypes().length; i++) {325 this.constructorsParametsType[i] = constructor326 .getParameterTypes()[i].getSimpleName();327 this.constructorsParametsTypeClass[i] = constructor328 .getParameterTypes()[i];329 }330 } else {331 // if (hasRunWithSuite && hasSuiteClasses) {332 if (hasSuiteClasses()) {333 if (this.hasRunWithCategories) {334 if (inCategory != null) {335 addIncludeCategoryClass(inCategory);336 }337 if (exCategory != null) {338 addExcludeCategoryClass(exCategory);339 }340 }341 for (Class<?> clz : suits) {342 // Lookup all @Suite classes and add new object of343 // ClassRecords, so that each class can contains their own344 // properties345 this.suiteClasses.add(new ClassRecords(clz, this));346 }347 }348 }349 }350 /**351 * <li><strong><i>getConstructorsParametsType</i></strong></li>352 * 353 * <pre>354 * public Object[] getConstructorsParametsType()355 * </pre>356 * 357 * <p>358 * Return Object[] array that contains data type of class constructor in359 * actual order only SIMPLE NAME. especially used for360 * RunWith(Parameterized.class)361 * </p>362 * 363 * @return Object[] - return constructors parameters type name364 * 365 * @author Shohel Shamim366 */367 public Object[] getConstructorsParametsType() {368 return this.constructorsParametsType;369 }370 /**371 * <li><strong><i>getConstructorsParametsTypeClass</i></strong></li>372 * 373 * <pre>374 * public Class<?>[] getConstructorsParametsTypeClass()375 * </pre>376 * 377 * <p>378 * Return Object[] array that contains data type of class constructor in379 * actual order, Type is Class. especially used for380 * RunWith(Parameterized.class)381 * </p>382 * 383 * @return Class<?>[] - return constructors parameters type class384 * 385 * @author Shohel Shamim386 */387 public Class<?>[] getConstructorsParametsTypeClass() {388 return this.constructorsParametsTypeClass;389 }390 /**391 * <li><strong><i>getEntryClass</i></strong></li>392 * 393 * <pre>394 * public Class<?> getEntryClass()395 * </pre>396 * 397 * <p>398 * Return class that is the entry point of a test class that was used to399 * create ClassRecords400 * </p>401 * 402 * @return Class<?>[] - return class type403 * 404 * @author Shohel Shamim405 */406 public Class<?> getEntryClass() {407 return this.claz;408 }409 /**410 * <li><strong><i>getExcludeCategoryClass</i></strong></li>411 * 412 * <pre>413 * public List<Class<?>> getExcludeCategoryClass()414 * </pre>415 * 416 * <p>417 * Return List of classes of ExcludeCategory.418 * </p>419 * 420 * @return List<Class<?>> - return List of class type421 * 422 * @author Shohel Shamim423 */424 public List<Class<?>> getExcludeCategoryClass() {425 return this.excludeCategory;426 }427 /**428 * <li><strong><i>getIncludeCategoryClass</i></strong></li>429 * 430 * <pre>431 * public List<Class<?>> getIncludeCategoryClass()432 * </pre>433 * 434 * <p>435 * Return List of classes of IncludeCategory.436 * </p>437 * 438 * @return List<Class<?>> - return List of class type439 * 440 * @author Shohel Shamim441 */442 public List<Class<?>> getIncludeCategoryClass() {443 return this.includeCategory;444 }445 /**446 * <li><strong><i>getParameterizedMethodsData</i></strong></li>447 * 448 * <pre>449 * public Collection<?> getParameterizedMethodsData()450 * </pre>451 * 452 * <p>453 * Return parameters data.454 * </p>455 * 456 * @return Collection<?> - return Collection of Parameterized Methods values457 * 458 * @author Shohel Shamim459 */460 public Collection<?> getParameterizedMethodsData() {461 return this.parametersData;462 }463 /**464 * <li><strong><i>getParentofEntryClassRecord</i></strong></li>465 * 466 * <pre>467 * public ClassRecords getParentofEntryClassRecord()468 * </pre>469 * 470 * <p>471 * Return Parent class record if any, if current class is invoked from a472 * Suite class then that class is the parent of this class record. it's not473 * like super class and base class recorded. It's like keeping reference.474 * </p>475 * 476 * @return ClassRecords - return parent ClassRecords477 * 478 * @author Shohel Shamim479 */480 public ClassRecords getParentofEntryClassRecord() {481 return this.parentClassRecord;482 }483 /**484 * <li><strong><i>getSuiteClasses</i></strong></li>485 * 486 * <pre>487 * public List<ClassRecords> getSuiteClasses()488 * </pre>489 * 490 * <p>491 * Return List of all suited class records those are annotated by492 * SuiteClasses{{}}.493 * </p>494 * 495 * @return List<ClassRecords> - return list of ClassRecords496 * 497 * @author Shohel Shamim498 */499 public List<ClassRecords> getSuiteClasses() {500 return this.suiteClasses;501 }502 /**503 * <li><strong><i>hasRunWithCategories</i></strong></li>504 * 505 * <pre>506 * public boolean hasRunWithCategories()507 * </pre>508 * 509 * <p>510 * Return true if class has RunWith(Categories.class) annotation.511 * </p>512 * 513 * @return boolean - return true or false514 * 515 * @author Shohel Shamim516 */517 public boolean hasRunWithCategories() {518 // both required to run them519 return (this.hasRunWithCategories && this.hasSuiteClasses);520 }521 /**522 * <li><strong><i>hasRunWithCategoriesAtItsPath</i></strong></li>523 * 524 * <pre>525 * public boolean hasRunWithCategoriesAtItsPath()526 * </pre>527 * 528 * <p>529 * Return true or false by looking up on its path. If this class530 * hasRunWithCategories is false then it will look through its previous531 * classes. lookupCategoriesAtItsPath = true, if found at any level of532 * parent class record of current class so, that it can determine weather533 * class should check for Category or not. Example: ClassA -> ClassB,534 * ClassC; ClassB -> ClassD, ClassE; now if ClassA is not true for Category,535 * but ClassB is true. Then, Category is True will work for all child of536 * ClassB -> ClassD, ClassE. But ClassC will be false for Category because537 * its root(s) (any level) are(is) not true.538 * </p>539 * 540 * @return boolean - return true or false541 * 542 * @author Shohel Shamim543 */544 public boolean hasRunWithCategoriesAtItsPath() {545 return this.hasRunWithCategoriesAtItsPath;546 }547 /**548 * <li><strong><i>hasRunWithParameterized</i></strong></li>549 * 550 * <pre>551 * public boolean hasRunWithParameterized()552 * </pre>553 * 554 * <p>555 * Return true if class has RunWith(Parameterized.class) annotation.556 * </p>557 * 558 * @return boolean - return true or false559 * 560 * @author Shohel Shamim561 */562 public boolean hasRunWithParameterized() {563 return this.hasRunWithParameterized;564 }565 /**566 * <li><strong><i>hasRunWithSuite</i></strong></li>567 * 568 * <pre>569 * public boolean hasRunWithSuite()570 * </pre>571 * 572 * <p>573 * Return true if class has RunWith(Suite.class) annotation.574 * </p>575 * 576 * @return boolean - return true or false577 * 578 * @author Shohel Shamim579 */580 public boolean hasRunWithSuite() {581 // both req. to run them582 return (this.hasRunWithSuite && this.hasSuiteClasses);583 }584 /**585 * <li><strong><i>hasRunWithSuiteOrCategories</i></strong></li>586 * 587 * <pre>588 * public boolean hasRunWithSuiteOrCategories()589 * </pre>590 * 591 * <p>592 * Return true if class has RunWith(Suite.class) or593 * RunWith(Categories.class)annotation.594 * </p>595 * 596 * @return boolean - return true or false597 * 598 * @author Shohel Shamim599 */600 public boolean hasRunWithSuiteOrCategories() {601 // both req. to run them602 return (hasRunWithSuite() || hasRunWithCategories());603 }604 /**605 * <li><strong><i>hasRunWithTheories</i></strong></li>606 * 607 * <pre>608 * public boolean hasRunWithTheories()609 * </pre>610 * 611 * <p>612 * Return true if class has RunWith(Theories.class) annotation.613 * </p>614 * 615 * @return boolean - return true or false616 * 617 * @author Shohel Shamim618 */619 public boolean hasRunWithTheories() {620 return this.hasRunWithTheories;621 }622 /**623 * <li><strong><i>hasSuiteClasses</i></strong></li>624 * 625 * <pre>626 * public boolean hasSuiteClasses()627 * </pre>628 * 629 * <p>630 * Return true if class has SuiteClasses.631 * </p>632 * 633 * @return boolean - return true or false634 * 635 * @author Shohel Shamim636 */637 public boolean hasSuiteClasses() {638 return (this.hasRunWithSuite && this.hasSuiteClasses)639 || ((this.hasRunWithCategories && this.hasSuiteClasses));640 }641 /**642 * <li><strong><i>isIgnored</i></strong></li>643 * 644 * <pre>645 * public boolean isIgnored()646 * </pre>647 * 648 * <p>649 * Return true if class has Ignore annotation.650 * </p>651 * 652 * @return boolean - return true or false653 * 654 * @author Shohel Shamim655 */656 public boolean isIgnored() {657 return this.isIgnored;658 }659 /**660 * <li><strong><i>resetValues</i></strong></li>661 * 662 * <pre>663 * private void resetValues()664 * </pre>665 * 666 * <p>667 * Reset essential properties if class has Ignore annotation.668 * </p>669 * 670 * 671 * @author Shohel Shamim672 */673 private void resetValues() {674 this.hasSuiteClasses = false;675 this.hasRunWithSuite = false;676 this.hasRunWithCategories = false;677 this.hasRunWithTheories = false;678 this.hasRunWithParameterized = false;679 this.hasRunWithCategoriesAtItsPath = false;680 }681 /**682 * <li><strong><i>setParameterizedMethodsData</i></strong></li>683 * 684 * <pre>685 * public void setParameterizedMethodsData(Collection<?> data)686 * </pre>687 * 688 * <p>689 * Keep values from Parameterized methods. A method that is annotated by690 * Parameters return Collection data type.691 * </p>692 * 693 * @param data694 * - a Collection type data695 * 696 * @author Shohel Shamim697 */698 public void setParameterizedMethodsData(Collection<?> data) {699 if (this.parametersData == null || this.parametersData.isEmpty()) {700 this.parametersData = data;701 }702 }703}...

Full Screen

Full Screen

Source:RequirementAwareSuite.java Github

copy

Full Screen

1package org.jboss.tools.ui.bot.ext;23import java.awt.AWTException;4import java.io.File;5import java.io.IOException;6import java.lang.reflect.Method;7import java.lang.reflect.Modifier;8import java.util.ArrayList;9import java.util.Arrays;10import java.util.Collections;11import java.util.HashSet;12import java.util.List;13import java.util.Map.Entry;14import java.util.Set;15import java.util.TreeSet;1617import org.apache.log4j.Logger;18import org.eclipse.swtbot.swt.finder.junit.ScreenshotCaptureListener;19import org.jboss.tools.test.util.ScreenRecorderExt;20import org.jboss.tools.ui.bot.ext.config.Annotations.Require;21import org.jboss.tools.ui.bot.ext.config.TestConfiguration;22import org.jboss.tools.ui.bot.ext.config.TestConfigurator;23import org.jboss.tools.ui.bot.ext.config.requirement.RequirementBase;24import org.junit.Test;25import org.junit.experimental.categories.Categories.ExcludeCategory;26import org.junit.experimental.categories.Categories.IncludeCategory;27import org.junit.experimental.categories.Category;28import org.junit.runner.Description;29import org.junit.runner.Runner;30import org.junit.runner.manipulation.Filter;31import org.junit.runner.manipulation.NoTestsRemainException;32import org.junit.runner.notification.RunListener;33import org.junit.runner.notification.RunNotifier;34import org.junit.runners.BlockJUnit4ClassRunner;35import org.junit.runners.Suite;36import org.junit.runners.model.FrameworkMethod;37import org.junit.runners.model.InitializationError;38import org.junit.runners.model.RunnerBuilder;39import org.junit.runners.model.Statement;4041/**42 * JUnit4 requirement aware testsuite runner. If suite class is annotated by @43 * RunWith({@link RequirementAwareSuite}) class, test classes can have44 * {@link Require} annotations45 * 46 * @author lzoubek@redhat.com47 */48public class RequirementAwareSuite extends Suite {49 private static boolean runManageBlockingWindow = true;50 private static ScreenRecorderExt screenRecorderExt = null;51 // we have one global instance of cleanup listener52 final static DoAfterAllTestsRunListener cleanUp = new DoAfterAllTestsRunListener();5354 final Filter categoryFilter;5556 public static class CategoryFilter extends Filter {57 public static CategoryFilter include(Class<?> categoryType) {58 return new CategoryFilter(categoryType, null);59 }6061 private final Class<?> fIncluded;62 private final Class<?> fExcluded;6364 public CategoryFilter(Class<?> includedCategory,65 Class<?> excludedCategory) {66 fIncluded = includedCategory;67 fExcluded = excludedCategory;68 }6970 @Override71 public String describe() {72 return "category " + fIncluded;73 }7475 @Override76 public boolean shouldRun(Description description) {77 if (hasCorrectCategoryAnnotation(description))78 return true;79 for (Description each : description.getChildren())80 if (shouldRun(each))81 return true;82 return false;83 }8485 private boolean hasCorrectCategoryAnnotation(Description description) {86 List<Class<?>> categories = categories(description);87 if (categories.isEmpty())88 return fIncluded == null;89 for (Class<?> each : categories)90 if (fExcluded != null && fExcluded.isAssignableFrom(each))91 return false;92 for (Class<?> each : categories)93 if (fIncluded == null || fIncluded.isAssignableFrom(each))94 return true;95 return false;96 }9798 private List<Class<?>> categories(Description description) {99 ArrayList<Class<?>> categories = new ArrayList<Class<?>>();100 categories.addAll(Arrays.asList(directCategories(description)));101 // categories.addAll(Arrays.asList(directCategories(parentDescription(description))));102 return categories;103 }104105 private Description parentDescription(Description description) {106 // TODO: how heavy are we cringing?107 return Description.createSuiteDescription(description108 .getTestClass());109 }110111 private Class<?>[] directCategories(Description description) {112 Category annotation = description.getAnnotation(Category.class);113 if (annotation == null)114 return new Class<?>[0];115 return annotation.value();116 }117 }118119 class ReqAwareClassRunner extends BlockJUnit4ClassRunner {120 private final TestConfiguration config;121 private final List<RequirementBase> requirements;122123 public ReqAwareClassRunner(Class<?> klass,124 List<RequirementBase> requirements, TestConfiguration config)125 throws InitializationError {126 super(klass);127 this.requirements = requirements;128 this.config = config;129130 try {131 if (categoryFilter != null){132 filter(categoryFilter); 133 }134 } catch (NoTestsRemainException e) {135 // TODO Auto-generated catch block136 throw new InitializationError(e);137 }138139 }140 141142 public List<RequirementBase> getRequirements() {143 return Collections.unmodifiableList(this.requirements);144 }145 146 @Override147 protected List<FrameworkMethod> computeTestMethods() {148 List<FrameworkMethod> testMethods = new ArrayList<FrameworkMethod>(); 149 for (Method mm : getTestClass().getJavaClass().getMethods()) {150 if (mm.getAnnotation(Test.class)!=null 151 ||152 (mm.getName().startsWith("test") 153 && !Modifier.isStatic(mm.getModifiers())154 && mm.getParameterTypes().length==0155 && Void.TYPE.equals(mm.getReturnType())156 )) {157 testMethods.add(new FrameworkMethod(mm));158 }159 }160 for (FrameworkMethod method : testMethods) {161 method.getAnnotation(Category.class);162 }163 return testMethods;164 }165 166167 @Override168 public void run(RunNotifier notifier) {169 // planned test counter must know about all tests (methods) within a170 // class171 cleanUp.incrPlanned(getChildren().size() - 1);172 // ensure that we have exactly 1 cleanup listener registered173 notifier.removeListener(cleanUp);174 notifier.addListener(cleanUp);175 // adding ability to create screen shot (taken from176 // SWTBotJunit4ClassRunner)177 RunListener failureSpy = new ScreenshotCaptureListener();178 notifier.removeListener(failureSpy);179 notifier.addListener(failureSpy);180 try {181 super.run(notifier);182 } finally {183 if (System.getProperty("swt.bot.test.record.screencast","false").equalsIgnoreCase("true")){184 RequirementAwareSuite.stopScreenRecorder();185 }186 notifier.removeListener(failureSpy);187 }188 }189190 @Override191 protected String testName(FrameworkMethod method) {192 return config.getPropName() + " - " + method.getName();193 }194195 @Override196 protected Statement withBeforeClasses(Statement statement) {197 if (System.getProperty("swt.bot.test.record.screencast","false").equalsIgnoreCase("true")){198 RequirementAwareSuite.startScreenRecorder(getTestClass().getJavaClass().getSimpleName());199 }200 201 MacSpecifics.setupToolkit();202 203 if (RequirementAwareSuite.runManageBlockingWindow){204 SWTJBTExt.manageBlockingWidows(false, false);205 RequirementAwareSuite.runManageBlockingWindow = false;206 }207 208 MacSpecifics.setupJava();209 210 if (!this.config.equals(TestConfigurator.currentConfig)) {211 TestConfigurator.currentConfig = this.config;212 }213 log.info("Fullfilling requirements before test "214 + getTestClass().getJavaClass());215216 try {217 for (RequirementBase r : requirements) {218 r.fulfill();219 }220 } catch (Exception e) {221 log.error("Fulfilling failed", e);222 }223 log.info("Done");224225226 return super.withBeforeClasses(statement);227 }228 }229 230231 private static final Logger log = Logger232 .getLogger(RequirementAwareSuite.class);233234 private class RequirementAwareRunnerBuilder extends RunnerBuilder {235 private final TestConfiguration config;236237 public RequirementAwareRunnerBuilder(TestConfiguration config) {238 this.config = config;239 }240241 @Override242 public Runner runnerForClass(Class<?> klass) throws Throwable {243 if (!this.config.equals(TestConfigurator.currentConfig)) {244 TestConfigurator.currentConfig = this.config;245 }246 log.info("class " + klass.getCanonicalName());247 List<RequirementBase> reqs = TestConfigurator248 .getClassRequirements(klass);249 if (reqs != null) {250 if (cleanUp.isClassPlanned(klass)) {251 if (TestConfigurator.isRequiresRunOnce(klass)) {252 // class is already scheduled to run and contains253 // annotation runOnce254 log.info("runOnce=true, class already planned");255 log.info("Skipped");256 return null;257 }258 if (!TestConfigurator.isRequiresAnyRuntime(klass)) {259 // class is scheduled and does not require any runtime, thus260 // no need to run it against other configuration261 log.info("no runtimes required + class already planned");262 log.info("Skipped");263 return null;264 }265 }266 log.info("OK");267 // increment number of tests planned to run by 1 (class contains268 // at least 1 test method)269 cleanUp.incrPlanned();270 cleanUp.addClass(klass);271 return new ReqAwareClassRunner(klass, reqs, config);272 }273 log.info("Skipped");274 cleanUp.addSkippedClass(klass);275 return null;276 }277278 }279280 /**281 * listener which listens to test runs, does some cleanup after all tests282 * have run it also holds set of all classes which run (usefull for runOnce283 * annotation)284 * 285 * @author lzoubek286 * 287 */288 static class DoAfterAllTestsRunListener extends RunListener {289 // As we can run more suites at once, we need to count tests which are290 // planned to run291 // and the ones which already passed (or failed), perform cleanups when292 // the last one finishes293 private int testsAboutToRun = 0;294 private int testsFinished = 0;295296 public void incrPlanned() {297 testsAboutToRun += 1;298 }299300 /**301 * adds class to the list of skipped classes302 * 303 * @param klass304 */305 public void addSkippedClass(Class<?> klass) {306 skippedClasses.add(klass.getName());307308 }309310 public void incrPlanned(int amount) {311 testsAboutToRun += amount;312 }313314 public void incrFinished() {315 testsFinished += 1;316 }317318 public int getPlanned() {319 return testsAboutToRun;320 }321322 public int getFinished() {323 return testsFinished;324 }325326 private Set<String> classes = new HashSet<String>();327328 /**329 * adds class to runList - as it is planned to run330 * 331 * @param klass332 */333 public void addClass(Class<?> klass) {334 classes.add(klass.getName());335 }336337 public boolean isClassPlanned(Class<?> klass) {338 return classes.contains(klass.getName());339 }340341 /**342 * set of classes that has been skipped (annotations not met etc)343 */344 private Set<String> skippedClasses = new TreeSet<String>();345346 private void reportSkippedClasses() {347 Set<String> finalized = new TreeSet<String>();348 // lets figure out if a class that has been at least once skipped349 // was not planned350 for (String clazz : skippedClasses) {351 if (!classes.contains(clazz)) {352 finalized.add(clazz);353 }354 }355 if (!finalized.isEmpty()) {356 log.info("Several test classes have been skipped, see head of log to figure out why it happened");357 for (String clazz : finalized) {358 log.info(" * " + clazz);359 }360 }361 }362363 @Override364 public void testFinished(Description description) throws Exception {365 incrFinished();366 log.info("Finished test : " + description.getDisplayName());367 log.info("Finished tests : " + getFinished() + "/" + getPlanned());368 if (getFinished() >= getPlanned()) {369 log.info("All tests finished, performing cleanup requirements ");370 try {371 RequirementBase.createStopServer().fulfill();372 RequirementBase.createStopDBServer().fulfill();373374 log.info("All cleanup requirements performed");375 } catch (Exception ex) {376 log.error("Unable to fulfill cleanup requirements", ex);377 }378 reportSkippedClasses();379 }380 super.testFinished(description);381 }382 }383384 private final ArrayList<Runner> runners = new ArrayList<Runner>();385386 /**387 * Only called reflectively. Do not use programmatically.388 */389390 /**391 * Called reflectively on classes annotated with392 * <code>@RunWith(RequirementAwareSuite.class)</code>393 * 394 * @param klass395 * the root class396 */397 public RequirementAwareSuite(Class<?> klass) throws Throwable {398 super(klass, Collections.<Runner> emptyList());399 log.info("Loading test configurations");400401 for (Entry<Object, Object> entry : TestConfigurator.multiProperties402 .entrySet()) {403 try {404 TestConfiguration config = new TestConfiguration(entry.getKey()405 .toString(), entry.getValue().toString());406 String suiteName = config.getPropName() + " - "407 + klass.getCanonicalName();408 log.info("Determine whether test classes meet configuration");409 NamedSuite suite = new NamedSuite(klass,new RequirementAwareRunnerBuilder(config), suiteName);410 // when no class mathces given config, do not init it 411 if (suite.getRunnerCount()>0) {412 log.info("Configuration '"+config.getPropName()+"' initialized with "+suite.getRunnerCount()+" runners.");413 runners.add(suite);414 config.initialize();415 }416 else {417 log.info("Configuration '"+config.getPropName()+"' skipped, no runners"); 418 }419 } catch (Exception ex) {420 log.error("Error loading test configuration", ex);421 throw ex;422 }423 }424425 try {426 categoryFilter = new CategoryFilter(getIncludedCategory(klass),427 getExcludedCategory(klass));428 filter(categoryFilter);429430 } catch (NoTestsRemainException e) {431 throw new InitializationError(e);432 }433 }434435 @Override436 protected List<Runner> getChildren() {437 return runners;438 }439440 public class NamedSuite extends Suite {441 private final String suiteName;442443 public NamedSuite(Class<?> klass, RunnerBuilder builder, String name)444 throws InitializationError {445 super(klass, builder);446 this.suiteName = name;447 }448 /**449 * gets count of test runners within this suite450 * @return451 */452 public int getRunnerCount() {453 return getChildren().size();454 }455456 @Override457 protected String getName() {458 return suiteName;459 }460 }461462 private Class<?> getIncludedCategory(Class<?> klass) {463 IncludeCategory annotation = klass.getAnnotation(IncludeCategory.class);464 return annotation == null ? null : annotation.value();465 }466467 private Class<?> getExcludedCategory(Class<?> klass) {468 ExcludeCategory annotation = klass.getAnnotation(ExcludeCategory.class);469 return annotation == null ? null : annotation.value();470 }471 /**472 * Starts Screen Recorder473 */474 private static void startScreenRecorder(String className) {475 if (screenRecorderExt == null) {476 try {477 screenRecorderExt = new ScreenRecorderExt();478 } catch (IOException ioe) {479 throw new RuntimeException("Unable to initialize Screen Recorder.", ioe);480 } catch (AWTException awte) {481 throw new RuntimeException("Unable to initialize Screen Recorder.", awte);482 }483 }484 if (screenRecorderExt != null) {485 if (screenRecorderExt.isState(ScreenRecorderExt.STATE_DONE)) {486 try {487 File screenCastDir = new File ("screencasts");488 if (!screenCastDir.exists()){489 screenCastDir.mkdir();490 }491 final String fileName = "screencasts" + File.separator + className;492 log.info("Starting Screen Recorder. Saving Screen Cast to file: " + fileName);493 screenRecorderExt.start(fileName);494 } catch (IOException ioe) {495 throw new RuntimeException("Unable to start Screen Recorder.", ioe);496 }497 } else {498 throw new RuntimeException(499 "Unable to start Screen Recorder.\nScreen Recorder is not in state DONE.");500 }501 } else {502 log.error("Screen Recorder was not properly initilized");503 }504 }505 /**506 * Stops Screen Recorder507 */508 private static void stopScreenRecorder(){509 if (screenRecorderExt != null){510 if (screenRecorderExt.isState(ScreenRecorderExt.STATE_RECORDING)){511 try {512 screenRecorderExt.stop();513 log.info("Screen Recorder stopped.");514 } catch (IOException ioe) {515 throw 516 new RuntimeException("Unable to stop Screen Recorder." , ioe);517 }518 }519 else{520 throw 521 new RuntimeException("Unable to stop Screen Recorder.\nScreen Recorder is no in state RECORDING.");522 }523 }524 else {525 throw 526 new RuntimeException("Unable to stop Screen Recorder.\nScreen Recorder was not properly initilized");527 }528 }529} ...

Full Screen

Full Screen

Source:AllUnitTestsSuite.java Github

copy

Full Screen

1/*2 * #%L3 * Alfresco Repository4 * %%5 * Copyright (C) 2005 - 2017 Alfresco Software Limited6 * %%7 * This file is part of the Alfresco software. 8 * If the software was purchased under a paid Alfresco license, the terms of 9 * the paid license agreement will prevail. Otherwise, the software is 10 * provided under the following open source license terms:11 * 12 * Alfresco is free software: you can redistribute it and/or modify13 * it under the terms of the GNU Lesser General Public License as published by14 * the Free Software Foundation, either version 3 of the License, or15 * (at your option) any later version.16 * 17 * Alfresco is distributed in the hope that it will be useful,18 * but WITHOUT ANY WARRANTY; without even the implied warranty of19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 * GNU Lesser General Public License for more details.21 * 22 * You should have received a copy of the GNU Lesser General Public License23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.24 * #L%25 */26package org.alfresco;2728import org.alfresco.util.testing.category.DBTests;29import org.alfresco.util.testing.category.NonBuildTests;30import org.junit.experimental.categories.Categories;31import org.junit.runner.RunWith;32import org.junit.runners.Suite;3334/**35 * All Repository project UNIT test classes (no application context) should be added to this test suite.36 * Tests marked as DBTests are automatically excluded and are run as part of {@link AllDBTestsTestSuite}.37 */38@RunWith(Categories.class)39@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})40@Suite.SuiteClasses({41 org.alfresco.repo.site.SiteMembershipTest.class,42 org.alfresco.encryption.EncryptorTest.class,43 org.alfresco.encryption.KeyStoreKeyProviderTest.class,44 org.alfresco.filesys.config.ServerConfigurationBeanTest.class,45 org.alfresco.filesys.repo.CIFSContentComparatorTest.class,46 org.alfresco.filesys.repo.rules.ShuffleTest.class,47 org.alfresco.repo.admin.Log4JHierarchyInitTest.class,48 org.alfresco.repo.attributes.PropTablesCleanupJobTest.class,49 org.alfresco.repo.cache.DefaultCacheFactoryTest.class,50 org.alfresco.repo.cache.DefaultSimpleCacheTest.class,51 org.alfresco.repo.cache.lookup.EntityLookupCacheTest.class,52 org.alfresco.repo.calendar.CalendarHelpersTest.class,53 org.alfresco.repo.dictionary.RepoDictionaryDAOTest.class,54 org.alfresco.repo.forms.processor.node.FieldProcessorTest.class,55 org.alfresco.repo.forms.processor.workflow.TaskFormProcessorTest.class,56 org.alfresco.repo.forms.processor.workflow.WorkflowFormProcessorTest.class,57 org.alfresco.repo.invitation.site.InviteSenderTest.class,58 org.alfresco.repo.invitation.site.InviteModeratedSenderTest.class,59 org.alfresco.repo.lock.LockUtilsTest.class,60 org.alfresco.repo.lock.mem.LockStoreImplTest.class,61 org.alfresco.repo.module.ModuleDetailsImplTest.class,62 org.alfresco.repo.module.ModuleVersionNumberTest.class,63 org.alfresco.repo.module.tool.ModuleManagementToolTest.class,64 org.alfresco.repo.module.tool.WarHelperImplTest.class,65 org.alfresco.repo.module.tool.ModuleServiceImplTest.class,66 org.alfresco.repo.policy.MTPolicyComponentTest.class,67 org.alfresco.repo.policy.PolicyComponentTest.class,68 org.alfresco.repo.rendition.RenditionNodeManagerTest.class,69 org.alfresco.repo.rendition.RenditionServiceImplTest.class,70 org.alfresco.repo.replication.ReplicationServiceImplTest.class,71 org.alfresco.repo.service.StoreRedirectorProxyFactoryTest.class,72 org.alfresco.repo.site.RoleComparatorImplTest.class,73 org.alfresco.repo.thumbnail.ThumbnailServiceImplParameterTest.class,74 org.alfresco.repo.transfer.ContentChunkerImplTest.class,75 org.alfresco.repo.transfer.HttpClientTransmitterImplTest.class,76 org.alfresco.repo.transfer.manifest.TransferManifestTest.class,77 org.alfresco.repo.transfer.TransferVersionCheckerImplTest.class,78 org.alfresco.repo.urlshortening.BitlyUrlShortenerTest.class,79 org.alfresco.service.cmr.calendar.CalendarRecurrenceHelperTest.class,80 org.alfresco.service.cmr.calendar.CalendarTimezoneHelperTest.class,81 org.alfresco.tools.RenameUserTest.class,82 org.alfresco.util.FileNameValidatorTest.class,83 org.alfresco.util.HttpClientHelperTest.class,84 org.alfresco.util.JSONtoFmModelTest.class,85 org.alfresco.util.ModelUtilTest.class,86 org.alfresco.util.PropertyMapTest.class,87 org.alfresco.util.ValueProtectingMapTest.class,88 org.alfresco.util.json.ExceptionJsonSerializerTest.class,89 org.alfresco.util.collections.CollectionUtilsTest.class,90 org.alfresco.util.schemacomp.DbObjectXMLTransformerTest.class,91 org.alfresco.util.schemacomp.DbPropertyTest.class,92 org.alfresco.util.schemacomp.DefaultComparisonUtilsTest.class,93 org.alfresco.util.schemacomp.DifferenceTest.class,94 org.alfresco.util.schemacomp.MultiFileDumperTest.class,95 org.alfresco.util.schemacomp.RedundantDbObjectTest.class,96 org.alfresco.util.schemacomp.SchemaComparatorTest.class,97 org.alfresco.util.schemacomp.SchemaToXMLTest.class,98 org.alfresco.util.schemacomp.ValidatingVisitorTest.class,99 org.alfresco.util.schemacomp.ValidationResultTest.class,100 org.alfresco.util.schemacomp.XMLToSchemaTest.class,101 org.alfresco.util.schemacomp.model.ColumnTest.class,102 org.alfresco.util.schemacomp.model.ForeignKeyTest.class,103 org.alfresco.util.schemacomp.model.IndexTest.class,104 org.alfresco.util.schemacomp.model.PrimaryKeyTest.class,105 org.alfresco.util.schemacomp.model.SchemaTest.class,106 org.alfresco.util.schemacomp.model.SequenceTest.class,107 org.alfresco.util.schemacomp.model.TableTest.class,108 org.alfresco.util.schemacomp.validator.IndexColumnsValidatorTest.class,109 org.alfresco.util.schemacomp.validator.NameValidatorTest.class,110 org.alfresco.util.schemacomp.validator.SchemaVersionValidatorTest.class,111 org.alfresco.util.schemacomp.validator.TypeNameOnlyValidatorTest.class,112 org.alfresco.util.test.junitrules.TemporaryMockOverrideTest.class,113 org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.class,114 org.alfresco.repo.search.impl.solr.SolrStatsResultTest.class,115 org.alfresco.repo.search.impl.solr.facet.SolrFacetComparatorTest.class,116 org.alfresco.repo.search.impl.solr.facet.FacetQNameUtilsTest.class,117 org.alfresco.util.BeanExtenderUnitTest.class,118 org.alfresco.repo.search.impl.solr.SpellCheckDecisionManagerTest.class,119 org.alfresco.repo.search.impl.solr.SolrStoreMappingWrapperTest.class,120 org.alfresco.repo.security.authentication.CompositePasswordEncoderTest.class,121 org.alfresco.repo.security.authentication.PasswordHashingTest.class,122 org.alfresco.traitextender.TraitExtenderIntegrationTest.class,123 org.alfresco.traitextender.AJExtensionsCompileTest.class,124125 org.alfresco.repo.virtual.page.PageCollatorTest.class,126 org.alfresco.repo.virtual.ref.GetChildByIdMethodTest.class,127 org.alfresco.repo.virtual.ref.GetParentReferenceMethodTest.class,128 org.alfresco.repo.virtual.ref.NewVirtualReferenceMethodTest.class,129 org.alfresco.repo.virtual.ref.PlainReferenceParserTest.class,130 org.alfresco.repo.virtual.ref.PlainStringifierTest.class,131 org.alfresco.repo.virtual.ref.ProtocolTest.class,132 org.alfresco.repo.virtual.ref.ReferenceTest.class,133 org.alfresco.repo.virtual.ref.ResourceParameterTest.class,134 org.alfresco.repo.virtual.ref.StringParameterTest.class,135 org.alfresco.repo.virtual.ref.VirtualProtocolTest.class,136 org.alfresco.repo.virtual.store.ReferenceComparatorTest.class,137138 org.alfresco.repo.virtual.ref.ZeroReferenceParserTest.class,139 org.alfresco.repo.virtual.ref.ZeroStringifierTest.class,140141 org.alfresco.repo.virtual.ref.HashStringifierTest.class,142 org.alfresco.repo.virtual.ref.NodeRefRadixHasherTest.class,143 org.alfresco.repo.virtual.ref.NumericPathHasherTest.class,144 org.alfresco.repo.virtual.ref.StoredPathHasherTest.class,145146 org.alfresco.repo.virtual.template.VirtualQueryImplTest.class,147 org.alfresco.repo.virtual.store.TypeVirtualizationMethodUnitTest.class,148149 org.alfresco.repo.security.authentication.AuthenticationServiceImplTest.class,150 org.alfresco.util.EmailHelperTest.class,151 org.alfresco.repo.action.ParameterDefinitionImplTest.class,152 org.alfresco.repo.action.ActionDefinitionImplTest.class,153 org.alfresco.repo.action.ActionConditionDefinitionImplTest.class,154 org.alfresco.repo.action.ActionImplTest.class,155 org.alfresco.repo.action.ActionConditionImplTest.class,156 org.alfresco.repo.action.CompositeActionImplTest.class,157 org.alfresco.repo.action.CompositeActionConditionImplTest.class,158 org.alfresco.repo.audit.AuditableAnnotationTest.class,159 org.alfresco.repo.audit.PropertyAuditFilterTest.class,160 org.alfresco.repo.content.filestore.SpoofedTextContentReaderTest.class,161 org.alfresco.repo.content.ContentDataTest.class,162 org.alfresco.service.cmr.repository.TransformationOptionLimitsTest.class,163 org.alfresco.service.cmr.repository.TransformationOptionPairTest.class,164 org.alfresco.repo.content.transform.TransformerConfigTestSuite.class,165 org.alfresco.service.cmr.repository.TemporalSourceOptionsTest.class,166 org.alfresco.repo.content.metadata.MetadataExtracterLimitsTest.class,167 org.alfresco.repo.content.caching.quota.StandardQuotaStrategyMockTest.class,168 org.alfresco.repo.content.caching.quota.UnlimitedQuotaStrategyTest.class,169 org.alfresco.repo.content.caching.CachingContentStoreTest.class,170 org.alfresco.repo.content.caching.ContentCacheImplTest.class,171 org.alfresco.repo.domain.propval.PropertyTypeConverterTest.class,172 org.alfresco.repo.search.MLAnaysisModeExpansionTest.class,173 org.alfresco.repo.search.DocumentNavigatorTest.class,174 org.alfresco.util.NumericEncodingTest.class,175 org.alfresco.repo.search.impl.parsers.CMIS_FTSTest.class,176 org.alfresco.repo.search.impl.parsers.CMISTest.class,177 org.alfresco.repo.search.impl.parsers.FTSTest.class,178 org.alfresco.repo.security.authentication.AlfrescoSSLSocketFactoryTest.class,179 org.alfresco.repo.security.authentication.AuthorizationTest.class,180 org.alfresco.repo.security.permissions.impl.acegi.FilteringResultSetTest.class,181 org.alfresco.repo.security.authentication.ChainingAuthenticationServiceTest.class,182 org.alfresco.repo.security.authentication.NameBasedUserNameGeneratorTest.class,183 org.alfresco.repo.version.common.VersionImplTest.class,184 org.alfresco.repo.version.common.VersionHistoryImplTest.class,185 org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicyTest.class,186 org.alfresco.repo.workflow.activiti.WorklfowObjectFactoryTest.class,187 org.alfresco.repo.workflow.WorkflowSuiteContextShutdownTest.class,188 org.alfresco.repo.search.impl.lucene.analysis.PathTokenFilterTest.class,189 190 org.alfresco.heartbeat.HBDataCollectorServiceImplTest.class,191 org.alfresco.heartbeat.HeartBeatJobTest.class,192 org.alfresco.heartbeat.AuthoritiesDataCollectorTest.class,193 org.alfresco.heartbeat.ConfigurationDataCollectorTest.class,194 org.alfresco.heartbeat.InfoDataCollectorTest.class,195 org.alfresco.heartbeat.ModelUsageDataCollectorTest.class,196 org.alfresco.heartbeat.SystemUsageDataCollectorTest.class197})198public class AllUnitTestsSuite199{200} ...

Full Screen

Full Screen

Source:AppContextExtraTestSuite.java Github

copy

Full Screen

1/*2 * #%L3 * Alfresco Repository4 * %%5 * Copyright (C) 2005 - 2017 Alfresco Software Limited6 * %%7 * This file is part of the Alfresco software. 8 * If the software was purchased under a paid Alfresco license, the terms of 9 * the paid license agreement will prevail. Otherwise, the software is 10 * provided under the following open source license terms:11 * 12 * Alfresco is free software: you can redistribute it and/or modify13 * it under the terms of the GNU Lesser General Public License as published by14 * the Free Software Foundation, either version 3 of the License, or15 * (at your option) any later version.16 * 17 * Alfresco is distributed in the hope that it will be useful,18 * but WITHOUT ANY WARRANTY; without even the implied warranty of19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 * GNU Lesser General Public License for more details.21 * 22 * You should have received a copy of the GNU Lesser General Public License23 * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.24 * #L%25 */26package org.alfresco;27import org.alfresco.util.testing.category.DBTests;28import org.alfresco.util.testing.category.NonBuildTests;29import org.junit.experimental.categories.Categories;30import org.junit.runner.RunWith;31import org.junit.runners.Suite;32/**33 * Repository project tests using the main context alfresco/application-context.xml PLUS some additional context.34 * Tests marked as DBTests are automatically excluded and are run as part of {@link AllDBTestsTestSuite}.35 */36@RunWith(Categories.class)37@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})38@Suite.SuiteClasses({39 // ----------------------------------------------------------------------40 // globalIntegrationTestContext [classpath:alfresco/application-context.xml, classpath:alfresco/test/global-integration-test-context.xml]41 // ----------------------------------------------------------------------42 org.alfresco.repo.action.executer.MailActionExecuterTest.class,43 org.alfresco.repo.action.ActionServiceImpl2Test.class,44 org.alfresco.repo.action.executer.ImporterActionExecuterTest.class,45 org.alfresco.repo.dictionary.CustomModelServiceImplTest.class,46 org.alfresco.repo.dictionary.ValueDataTypeValidatorImplTest.class,47 org.alfresco.repo.download.DownloadServiceIntegrationTest.class,48 org.alfresco.repo.forum.CommentsTest.class,49 org.alfresco.repo.jscript.ScriptNodeTest.class,50 org.alfresco.repo.preference.PreferenceServiceImplTest.class,51 org.alfresco.repo.rule.MiscellaneousRulesTest.class,52 org.alfresco.repo.rule.RuleServiceIntegrationTest.class,53 org.alfresco.repo.security.authentication.ResetPasswordServiceImplTest.class,54 org.alfresco.repo.subscriptions.SubscriptionServiceActivitiesTest.class,55 org.alfresco.util.test.junitrules.AlfrescoPersonTest.class,56 // the following test only passes on a clean DB57 org.alfresco.util.test.junitrules.TemporaryNodesTest.class,58 org.alfresco.repo.search.impl.solr.facet.SolrFacetQueriesDisplayHandlersTest.class,59 org.alfresco.repo.search.impl.solr.facet.SolrFacetServiceImplTest.class,60 org.alfresco.repo.invitation.InvitationCleanupTest.class,61 org.alfresco.repo.quickshare.QuickShareServiceIntegrationTest.class,62 org.alfresco.repo.remotecredentials.RemoteCredentialsServicesTest.class,63 // ----------------------------------------------------------------------64 // Context_extra65 // ----------------------------------------------------------------------66 // [classpath:alfresco/application-context.xml, classpath:org/alfresco/repo/site/site-custom-context.xml]67 org.alfresco.repo.site.SiteServiceImplTest.class,68 // [classpath:alfresco/application-context.xml, classpath:scriptexec/script-exec-test.xml]69 org.alfresco.repo.domain.schema.script.ScriptExecutorImplIntegrationTest.class,70 org.alfresco.repo.domain.schema.script.ScriptBundleExecutorImplIntegrationTest.class,71 // [classpath:alfresco/application-context.xml, classpath:alfresco/test/global-integration-test-context.xml,72 // classpath:org/alfresco/util/test/junitrules/dummy1-context.xml,73 // classpath:org/alfresco/util/test/junitrules/dummy2-context.xml]74 org.alfresco.util.test.junitrules.ApplicationContextInitTest.class,75 // [classpath:alfresco/application-context.xml,76 // classpath:org/alfresco/repo/client/config/test-repo-clients-apps-context.xml]77 org.alfresco.repo.client.config.ClientAppConfigTest.class,78 // [classpath:alfresco/application-context.xml,79 // classpath:org/alfresco/repo/policy/annotation/test-qname-type-editor-context.xml]80 org.alfresco.repo.policy.annotation.QNameTypeEditorTest.class,81 // [classpath:alfresco/application-context.xml, classpath:org/alfresco/repo/forms/MNT-7383-context.xml]82 org.alfresco.repo.forms.processor.action.ActionFormProcessorTest.class,83 // [classpath:alfresco/application-context.xml, classpath:alfresco/filesys/auth/cifs/test-kerberos-context.xml]84 org.alfresco.filesys.auth.cifs.CifsAuthenticatorKerberosTest.class,85 // [classpath:alfresco/application-context.xml, classpath:test-cmisinteger_modell-context.xml]86 org.alfresco.opencmis.CMISTest.class,87 // [classpath:alfresco/application-context.xml, classpath:org/alfresco/repo/action/test-action-services-context.xml]88 org.alfresco.repo.action.ActionServiceImplTest.class,89 // [classpath:alfresco/application-context.xml, classpath:alfresco/test/global-integration-test-context.xml,90 // classpath:ratings/test-RatingServiceIntegrationTest-context.xml]91 org.alfresco.repo.rating.RatingServiceIntegrationTest.class,92 // [classpath:alfresco/application-context.xml, classpath:sync-test-context.xml]93 org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizerTest.class,94 // [classpath:alfresco/application-context.xml, classpath:alfresco/test/global-integration-test-context.xml,95 // classpath:sites/test-TemporarySitesTest-context.xml]96 org.alfresco.repo.site.SiteServiceImplMoreTest.class,97 org.alfresco.util.test.junitrules.TemporarySitesTest.class,98 // ======================================================================99 // any other order may lead to failing tests100 // ======================================================================101 // ----------------------------------------------------------------------102 // virtualizationTestContext [classpath:**/virtualization-test-context.xml, classpath:alfresco/application-context.xml]103 // ----------------------------------------------------------------------104 org.alfresco.repo.virtual.bundle.VirtualPreferenceServiceExtensionTest.class,105 org.alfresco.repo.virtual.bundle.VirtualLockableAspectInterceptorExtensionTest.class,106 org.alfresco.repo.virtual.bundle.VirtualVersionServiceExtensionTest.class,107 org.alfresco.repo.virtual.bundle.VirtualRatingServiceExtensionTest.class,108 org.alfresco.repo.virtual.bundle.VirtualCheckOutCheckInServiceExtensionTest.class,109 org.alfresco.repo.virtual.bundle.VirtualPermissionServiceExtensionTest.class,110 org.alfresco.repo.virtual.bundle.VirtualNodeServiceExtensionTest.class,111 org.alfresco.repo.virtual.bundle.VirtualFileFolderServiceExtensionTest.class,112 org.alfresco.repo.virtual.template.ApplyTemplateMethodTest.class,113 org.alfresco.repo.virtual.model.SystemTemplateLocationsConstraintTest.class,114 org.alfresco.repo.virtual.store.SystemVirtualizationMethodTest.class,115 org.alfresco.repo.virtual.store.TypeVirtualizationMethodIntegrationTest.class,116 org.alfresco.repo.virtual.template.TemplateResourceProcessorTest.class,117 org.alfresco.repo.virtual.store.VirtualStoreImplTest.class,118 org.alfresco.repo.virtual.config.NodeRefPathExpressionTest.class,119 org.alfresco.repo.virtual.template.TemplateFilingRuleTest.class,120 org.alfresco.repo.virtual.bundle.FileInfoPropsComparatorTest.class,121 // ----------------------------------------------------------------------122 // testSubscriptionsContext [classpath:alfresco/application-context.xml, classpath:test/alfresco/test-subscriptions-context.xml]123 // TODO can we remove this? Was it EOLed?124 // ----------------------------------------------------------------------125 org.alfresco.repo.subscriptions.SubscriptionServiceImplTest.class,126 // ----------------------------------------------------------------------127 // openCmisContext [classpath:alfresco/application-context.xml, classpath:opencmis/opencmistest-context.xml]128 // ----------------------------------------------------------------------129 org.alfresco.opencmis.OpenCmisLocalTest.class,130 // ----------------------------------------------------------------------131 // cacheTestContext [classpath:alfresco/application-context.xml, classpath:cache-test/cache-test-context.xml]132 // ----------------------------------------------------------------------133 org.alfresco.repo.cache.CacheTest.class,134 // ----------------------------------------------------------------------135 // mtAllContext [classpath:alfresco/application-context.xml, classpath:tenant/mt-*context.xml]136 // ----------------------------------------------------------------------137 org.alfresco.repo.tenant.MultiTDemoTest.class,138 org.alfresco.repo.workflow.activiti.ActivitiMultitenantWorkflowTest.class139})140public class AppContextExtraTestSuite141{142}...

Full Screen

Full Screen

Source:IntegrationTestSuite.java Github

copy

Full Screen

1package helpers.suite;2import config.TestHttpAppConfig;3import helpers.category.ServletContainerTest;4import helpers.category.UnitTests;5import net.tokensmith.authorization.http.controller.RSAPublicKeyResourceTest;6import net.tokensmith.authorization.http.controller.RSAPublicKeysResourceTest;7import net.tokensmith.authorization.http.controller.RegisterResourceTest;8import net.tokensmith.authorization.http.controller.WelcomeResourceTest;9import net.tokensmith.authorization.http.controller.authorization.AuthorizationResourceTest;10import net.tokensmith.authorization.http.controller.authorization.OAuth2CodeResourceTest;11import net.tokensmith.authorization.http.controller.authorization.OAuth2ImplicitResourceTest;12import net.tokensmith.authorization.http.controller.authorization.OpenIdCodeResourceTest;13import net.tokensmith.authorization.http.controller.authorization.OpenIdImplicitIdentityResourceTest;14import net.tokensmith.authorization.http.controller.authorization.OpenIdImplicitResourceTest;15import net.tokensmith.authorization.http.controller.resource.ForgotPasswordResourceTest;16import net.tokensmith.authorization.http.controller.resource.UpdatePasswordResourceTest;17import net.tokensmith.authorization.http.controller.resource.api.publik.HealthResourceTest;18import net.tokensmith.authorization.http.controller.resource.api.site.RestAddressResourceTest;19import net.tokensmith.authorization.http.controller.resource.api.site.RestProfileResourceTest;20import net.tokensmith.authorization.http.controller.resource.html.authorization.AuthorizationResource;21import net.tokensmith.authorization.http.controller.token.TokenResourceRefreshTokenTest;22import net.tokensmith.authorization.http.controller.token.TokenResourceResponseTypeCodeTest;23import net.tokensmith.authorization.http.controller.token.TokenResourceResponseTypePasswordTest;24import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOAuth2CodeTest;25import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOAuth2PasswordTest;26import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOAuth2RefreshTest;27import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOAuth2TokenTest;28import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOpenIdCodeTest;29import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOpenIdPasswordTest;30import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOpenIdRefreshTest;31import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceOpenIdTokenAndIdTokenTest;32import net.tokensmith.authorization.http.controller.userInfo.UserInfoResourceTest;33import net.tokensmith.otter.config.OtterAppFactory;34import net.tokensmith.otter.server.HttpServerConfig;35import net.tokensmith.otter.server.container.ServletContainer;36import net.tokensmith.otter.server.container.ServletContainerFactory;37import org.asynchttpclient.AsyncHttpClient;38import org.asynchttpclient.DefaultAsyncHttpClientConfig;39import org.junit.AfterClass;40import org.junit.BeforeClass;41import org.junit.experimental.categories.Categories;42import org.junit.runner.RunWith;43import org.junit.runners.Suite;44import org.springframework.context.annotation.AnnotationConfigApplicationContext;45import java.util.Arrays;46import java.util.List;47import static org.asynchttpclient.Dsl.asyncHttpClient;48@RunWith(Categories.class)49@Categories.IncludeCategory(ServletContainerTest.class)50@Categories.ExcludeCategory(UnitTests.class)51@Suite.SuiteClasses({52 AuthorizationResourceTest.class,53 OAuth2CodeResourceTest.class,54 OAuth2ImplicitResourceTest.class,55 OpenIdCodeResourceTest.class,56 OpenIdImplicitIdentityResourceTest.class,57 OpenIdImplicitResourceTest.class,58 TokenResourceResponseTypeCodeTest.class,59 TokenResourceResponseTypePasswordTest.class,60 TokenResourceRefreshTokenTest.class,61 UserInfoResourceTest.class,62 UserInfoResourceOpenIdPasswordTest.class,63 UserInfoResourceOpenIdCodeTest.class,64 UserInfoResourceOpenIdTokenAndIdTokenTest.class,65 UserInfoResourceOpenIdRefreshTest.class,66 UserInfoResourceOAuth2CodeTest.class,67 UserInfoResourceOAuth2PasswordTest.class,68 UserInfoResourceOAuth2RefreshTest.class,69 UserInfoResourceOAuth2TokenTest.class,70 RSAPublicKeysResourceTest.class,71 RSAPublicKeyResourceTest.class,72 RegisterResourceTest.class,73 WelcomeResourceTest.class,74 ForgotPasswordResourceTest.class,75 UpdatePasswordResourceTest.class,76 RestProfileResourceTest.class,77 RestAddressResourceTest.class,78 HealthResourceTest.class79})80public class IntegrationTestSuite {81 private static OtterAppFactory otterTestAppFactory;82 private static ServletContainerFactory servletContainerFactory;83 private static ServletContainer server;84 private static AsyncHttpClient httpClient;85 private static String DOCUMENT_ROOT = "/";86 private static int RANDOM_PORT = 0;87 private static String REQUEST_LOG = "logs/jetty/jetty-test-yyyy_mm_dd.request.log";88 private static AnnotationConfigApplicationContext context;89 private static void configureAndStartServletContainer() throws Exception {90 otterTestAppFactory = new OtterAppFactory();91 servletContainerFactory = otterTestAppFactory.servletContainerFactory();92 List<String> gzipMimeTypes = Arrays.asList(93 "text/html", "text/plain", "text/xml",94 "text/css", "application/javascript", "text/javascript",95 "application/json");96 HttpServerConfig config = new HttpServerConfig.Builder()97 .documentRoot(DOCUMENT_ROOT)98 .port(RANDOM_PORT)99 .requestLog(REQUEST_LOG)100 .clazz(AuthorizationResource.class)101 .gzipMimeTypes(gzipMimeTypes)102 .build();103 server = servletContainerFactory.makeServletContainer(config);104 server.start();105 httpClient = asyncHttpClient(new DefaultAsyncHttpClientConfig.Builder().setCookieStore(null).build());106 }107 /**108 * Starts a servlet container and a spring container.109 *110 * @throws Exception111 */112 @BeforeClass113 public static void beforeClass() throws Exception {114 configureAndStartServletContainer();115 context = new AnnotationConfigApplicationContext();116 context.register(TestHttpAppConfig.class);117 context.refresh();118 }119 /**120 * Stops a servlet container121 *122 * @throws Exception123 */124 @AfterClass125 public static void afterClass() throws Exception {126 server.stop();127 }128 public static ServletContainer getServer() {129 return server;130 }131 public static void setServer(ServletContainer server) {132 IntegrationTestSuite.server = server;133 }134 public static AsyncHttpClient getHttpClient() {135 return httpClient;136 }137 public static void setHttpClient(AsyncHttpClient httpClient) {138 IntegrationTestSuite.httpClient = httpClient;139 }140 public static AnnotationConfigApplicationContext getContext() {141 return context;142 }143}...

Full Screen

Full Screen

Source:ClassPathScanSuite.java Github

copy

Full Screen

1package firebats.test.junit;23import java.io.IOException;4import java.lang.annotation.ElementType;5import java.lang.annotation.Inherited;6import java.lang.annotation.Retention;7import java.lang.annotation.RetentionPolicy;8import java.lang.annotation.Target;910import javax.annotation.Nullable;1112import org.junit.experimental.categories.Categories.CategoryFilter;13import org.junit.experimental.categories.Categories.ExcludeCategory;14import org.junit.experimental.categories.Categories.IncludeCategory;15import org.junit.runner.Description;16import org.junit.runner.manipulation.Filter;17import org.junit.runner.manipulation.NoTestsRemainException;18import org.junit.runners.model.InitializationError;19import org.junit.runners.model.RunnerBuilder;2021import com.google.common.base.Function;22import com.google.common.base.Predicate;23import com.google.common.collect.FluentIterable;24import com.google.common.collect.ImmutableSet;25import com.google.common.collect.Iterables;26import com.google.common.reflect.ClassPath;27import com.google.common.reflect.ClassPath.ClassInfo;2829/**30 * 自动classpath查找Suite实现31 * 32 * 范例:33 * @RunWith(ClassPathSuite.class)34 * @IncludeCategory(SlowTestCategory.class)35 * @SuiteClasses(packageName="junit4")36 * public class AllSlowTests {37 * }38 * 39 * public interface SlowTestCategory {}40 * 41 * @Category(SlowTestCategory.class)42 * public class ASlowTest {43 * @Test public void test() {}44 * }45 */46public class ClassPathScanSuite extends org.junit.runners.Suite {47 /**48 * The <code>SuiteClasses</code> annotation specifies the classes to be run when a class49 * annotated with <code>@RunWith(Suite.class)</code> is run.50 */51 @Retention(RetentionPolicy.RUNTIME)52 @Target(ElementType.TYPE)53 @Inherited54 public @interface SuiteClasses {55 /**56 * @return the classes to be run57 */58 public String packageName();59 }6061 static public ClassPath classpath;62 static {63 try {64 classpath = ClassPath.from(Thread.currentThread().getContextClassLoader());65 } catch (IOException e) {66 throw new RuntimeException(e);67 }68 }697071 /**72 * for junit invoke.73 */74 public ClassPathScanSuite(Class<?> clazz, RunnerBuilder builder)75 throws InitializationError {76 super(builder, clazz, Iterables.toArray(getClasses(getPackageName(clazz), getIncludedCategory(clazz)), Class.class));77 CategoryFilter filter=new CategoryFilter(getIncludedCategory(clazz),getExcludedCategory(clazz));78 try {79 filter(new ClassPathCategoryFilter(getPackageName(clazz),filter));80 } catch (NoTestsRemainException e) {81 throw new InitializationError(e);82 }83 }84 85 public static class ClassPathCategoryFilter extends Filter {86 private String packageName;87 CategoryFilter filter;88 public ClassPathCategoryFilter(String packageName,CategoryFilter filter) {89 this.filter=filter;90 this.packageName=packageName;91 }92 @Override93 public boolean shouldRun(Description description) {94 if(description!=null&&description.getTestClass()!=null){95 return description.getTestClass().getPackage().getName().startsWith(packageName)96 &&filter.shouldRun(description);97 }98 return false;99 }100 @Override101 public String describe() { 102 return filter.describe() +" ,packages " +packageName;103 }104 }105106 private static ImmutableSet<Class<?>> getClasses(String packageName,107 final Class<?> annotationClass) {108 return FluentIterable109 .from(classpath.getTopLevelClassesRecursive(packageName))110 .filter(new Predicate<ClassPath.ClassInfo>() {111 @Override112 public boolean apply(ClassInfo input) {113 return true;114 }115 })116 .transform(new Function<ClassInfo, Class<?>>() {117 @Override118 @Nullable119 public Class<?> apply(@Nullable ClassInfo input) {120 try {121 return Class.forName(input.getName());122 } catch (ClassNotFoundException e) {123 throw new RuntimeException(e);124 }125 }126 })127 .filter(new Predicate<Class<?>>() {128 @Override129 public boolean apply(@Nullable Class<?> input) {130 return true;131 }132 }).toSet();133 }134 135 private static Class<?> getExcludedCategory(Class<?> klass) {136 ExcludeCategory annotation= klass.getAnnotation(ExcludeCategory.class);137 return annotation == null ? null : annotation.value();138 }139 private static Class<?> getIncludedCategory(Class<?> klass) {140 IncludeCategory annotation= klass.getAnnotation(IncludeCategory.class);141 return annotation == null ? null : annotation.value();142 }143 private static String getPackageName(Class<?> klass) {144 SuiteClasses annotation= klass.getAnnotation(SuiteClasses.class);145 return annotation == null ? "no package name" : annotation.packageName();146 }147} ...

Full Screen

Full Screen

Annotation Type Categories.ExcludeCategory

Using AI Code Generation

copy

Full Screen

1import org.junit.experimental.categories.Categories;2import org.junit.experimental.categories.Categories.ExcludeCategory;3import org.junit.runner.RunWith;4import org.junit.runners.Suite;5@RunWith(Categories.class)6@ExcludeCategory(PerformanceTest.class)7@Suite.SuiteClasses({A.class, B.class})8public class ExcludeCategoryTestSuite {9}10@Categories.ExcludeCategory(PerformanceTest.class)11@RunWith(Categories.class)12@ExcludeCategories({PerformanceTest.class, DatabaseTest.class})13@Suite.SuiteClasses({A.class, B.class})14public class ExcludeCategoriesTestSuite {15}16@Categories.ExcludeCategories({PerformanceTest.class, DatabaseTest.class})

Full Screen

Full Screen

Annotation Type Categories.ExcludeCategory

Using AI Code Generation

copy

Full Screen

1package com.java2novice.junit.categories; import org.junit.experimental.categories.Categories.ExcludeCategory; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Categories.class) @ExcludeCategory(SlowTests.class) @Suite.SuiteClasses({ TestJunit1.class, TestJunit2.class }) public class JunitTestSuite { }2package com.java2novice.junit.categories; import org.junit.experimental.categories.Category; public class TestJunit1 { @Category(SlowTests.class) public void test1() { System.out.println("TestJunit1.test1()"); } @Category(FastTests.class) public void test2() { System.out.println("TestJunit1.test2()"); } }3package com.java2novice.junit.categories; import org.junit.experimental.categories.Category; public class TestJunit2 { @Category(SlowTests.class) public void test3() { System.out.println("TestJunit2.test3()"); } @Category(FastTests.class) public void test4() { System.out.println("TestJunit2.test4()"); } }4package com.java2novice.junit.categories; public interface FastTests { /* category marker */ }5package com.java2novice.junit.categories; public interface SlowTests { /* category marker */ }6TestJunit1.test2()7TestJunit2.test4()8JUnit 5: @Tag, @Tag("fast"), @Tag("slow"),…9JUnit 5: @TestInstance, @TestInstance(Lifecycle.PER_CLASS)10JUnit 5: @Test, @Test(timeout = 100), @Test(expected = Exception.class)

Full Screen

Full Screen

JUnit Tutorial:

LambdaTest also has a detailed JUnit tutorial explaining its features, importance, advanced use cases, best practices, and more to help you get started with running your automation testing scripts.

JUnit Tutorial Chapters:

Here are the detailed JUnit testing chapters to help you get started:

  • Importance of Unit testing - Learn why Unit testing is essential during the development phase to identify bugs and errors.
  • Top Java Unit testing frameworks - Here are the upcoming JUnit automation testing frameworks that you can use in 2023 to boost your unit testing.
  • What is the JUnit framework
  • Why is JUnit testing important - Learn the importance and numerous benefits of using the JUnit testing framework.
  • Features of JUnit - Learn about the numerous features of JUnit and why developers prefer it.
  • JUnit 5 vs. JUnit 4: Differences - Here is a complete comparison between JUnit 5 and JUnit 4 testing frameworks.
  • Setting up the JUnit environment - Learn how to set up your JUnit testing environment.
  • Getting started with JUnit testing - After successfully setting up your JUnit environment, this chapter will help you get started with JUnit testing in no time.
  • Parallel testing with JUnit - Parallel Testing can be used to reduce test execution time and improve test efficiency. Learn how to perform parallel testing with JUnit.
  • Annotations in JUnit - When writing automation scripts with JUnit, we can use JUnit annotations to specify the type of methods in our test code. This helps us identify those methods when we run JUnit tests using Selenium WebDriver. Learn in detail what annotations are in JUnit.
  • Assertions in JUnit - Assertions are used to validate or test that the result of an action/functionality is the same as expected. Learn in detail what assertions are and how to use them while performing JUnit testing.
  • Parameterization in JUnit - Parameterized Test enables you to run the same automated test scripts with different variables. By collecting data on each method's test parameters, you can minimize time spent on writing tests. Learn how to use parameterization in JUnit.
  • Nested Tests In JUnit 5 - A nested class is a non-static class contained within another class in a hierarchical structure. It can share the state and setup of the outer class. Learn about nested annotations in JUnit 5 with examples.
  • Best practices for JUnit testing - Learn about the best practices, such as always testing key methods and classes, integrating JUnit tests with your build, and more to get the best possible results.
  • Advanced Use Cases for JUnit testing - Take a deep dive into the advanced use cases, such as how to run JUnit tests in Jupiter, how to use JUnit 5 Mockito for Unit testing, and more for JUnit testing.

JUnit Certification:

You can also check out our JUnit certification if you wish to take your career in Selenium automation testing with JUnit to the next level.

Run junit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful