Best Spectrum code snippet using com.greghaskins.spectrum.internal.Spec.Hooks
Source:Specification.java
1package com.greghaskins.spectrum.dsl.specification;2import static com.greghaskins.spectrum.Configure.focus;3import static com.greghaskins.spectrum.Configure.ignore;4import static com.greghaskins.spectrum.Configure.with;5import static com.greghaskins.spectrum.internal.hooks.AfterHook.after;6import static com.greghaskins.spectrum.internal.hooks.BeforeHook.before;7import com.greghaskins.spectrum.Block;8import com.greghaskins.spectrum.ThrowingConsumer;9import com.greghaskins.spectrum.ThrowingSupplier;10import com.greghaskins.spectrum.internal.DeclarationState;11import com.greghaskins.spectrum.internal.Suite;12import com.greghaskins.spectrum.internal.blocks.IdempotentBlock;13import com.greghaskins.spectrum.internal.hooks.EagerLetHook;14import com.greghaskins.spectrum.internal.hooks.Hook;15import com.greghaskins.spectrum.internal.hooks.HookContext.AppliesTo;16import com.greghaskins.spectrum.internal.hooks.HookContext.Precedence;17import com.greghaskins.spectrum.internal.hooks.LetHook;18import org.junit.AssumptionViolatedException;19import java.util.function.Supplier;20public interface Specification {21 /**22 * Declare a test suite that describes the expected behavior of the system in a given context.23 *24 * @param context Description of the context for this suite25 * @param block {@link Block} with one or more calls to {@link #it(String, Block) it} that26 * define each expected behavior27 */28 static void describe(final String context, final Block block) {29 final Suite suite = DeclarationState.instance()30 .getCurrentSuiteBeingDeclared()31 .addSuite(context);32 suite.applyConfigurationFromBlock(block);33 DeclarationState.instance().beginDeclaration(suite, block);34 }35 /**36 * Focus on this specific suite, while ignoring others.37 *38 * @param context Description of the context for this suite39 * @param block {@link Block} with one or more calls to {@link #it(String, Block) it} that40 * define each expected behavior41 * @see #describe(String, Block)42 */43 static void fdescribe(final String context, final Block block) {44 describe(context, with(focus(), block));45 }46 /**47 * Ignore the specific suite.48 *49 * @param context Description of the context for this suite50 * @param block {@link Block} with one or more calls to {@link #it(String, Block) it} that51 * define each expected behavior52 * @see #describe(String, Block)53 */54 static void xdescribe(final String context, final Block block) {55 describe(context, with(ignore(), block));56 }57 /**58 * Declare a spec, or test, for an expected behavior of the system in this suite context.59 *60 * @param behavior Description of the expected behavior61 * @param block {@link Block} that verifies the system behaves as expected and throws a {@link62 * java.lang.Throwable Throwable} if that expectation is not met.63 */64 static void it(final String behavior, final Block block) {65 DeclarationState.instance().getCurrentSuiteBeingDeclared().addSpec(behavior, block);66 }67 /**68 * Declare a pending spec (without a block) that will be ignored.69 *70 * @param behavior Description of the expected behavior71 * @see #xit(String, Block)72 */73 static void it(final String behavior) {74 DeclarationState.instance().getCurrentSuiteBeingDeclared().addSpec(behavior, null).ignore();75 }76 /**77 * Focus on this specific spec, while ignoring others.78 *79 * @param behavior Description of the expected behavior80 * @param block {@link Block} that verifies the system behaves as expected and throws a {@link81 * java.lang.Throwable Throwable} if that expectation is not met.82 * @see #it(String, Block)83 */84 static void fit(final String behavior, final Block block) {85 it(behavior, with(focus(), block));86 }87 /**88 * Mark a spec as ignored so that it will be skipped.89 *90 * @param behavior Description of the expected behavior91 * @param block {@link Block} that will not run, since this spec is ignored.92 * @see #it(String, Block)93 */94 static void xit(final String behavior, final Block block) {95 it(behavior);96 }97 /**98 * Declare a {@link Block} to be run before each spec in the suite.99 *100 * <p>101 * Use this to perform setup actions that are common across tests in the context. If multiple102 * {@code beforeEach} blocks are declared, they will run in declaration order.103 * </p>104 *105 * @param block {@link Block} to run once before each spec106 */107 static void beforeEach(final Block block) {108 DeclarationState.instance().addHook(before(block), AppliesTo.ATOMIC_ONLY, Precedence.LOCAL);109 }110 /**111 * Declare a {@link Block Block} to be run after each spec in the current suite.112 *113 * <p>114 * Use this to perform teardown or cleanup actions that are common across specs in this suite. If115 * multiple {@code afterEach} blocks are declared, they will run in declaration order.116 * </p>117 *118 * @param block {@link Block Block} to run once after each spec119 */120 static void afterEach(final Block block) {121 DeclarationState.instance().addHook(after(block), AppliesTo.ATOMIC_ONLY,122 Precedence.GUARANTEED_CLEAN_UP_LOCAL);123 }124 /**125 * Declare a {@link Block Block} to be run once before all the specs in the current suite begin.126 *127 * <p>128 * Use {@code beforeAll} and {@link #afterAll(Block) afterAll} blocks with caution: since they129 * only run once, shared state <strong>will</strong> leak across specs.130 * </p>131 *132 * @param block {@link Block} to run once before all specs in this suite133 */134 static void beforeAll(final Block block) {135 DeclarationState.instance().addHook(before(new IdempotentBlock(block)), AppliesTo.ATOMIC_ONLY,136 Precedence.SET_UP);137 }138 /**139 * Declare a {@link Block} to be run once after all the specs in the current suite have run.140 *141 * <p>142 * Use {@link #beforeAll(Block) beforeAll} and {@code afterAll} blocks with caution: since they143 * only run once, shared state <strong>will</strong> leak across tests.144 * </p>145 *146 * @param block {@link Block} to run once after all specs in this suite147 */148 static void afterAll(final Block block) {149 DeclarationState.instance().addHook(after(block), AppliesTo.ONCE,150 Precedence.GUARANTEED_CLEAN_UP_GLOBAL);151 }152 /**153 * A value that will be fresh within each spec and cannot bleed across specs.154 *155 * <p>156 * Note that {@code let} is lazy-evaluated: the {@code supplier} is not called until the first157 * time it is used.158 * </p>159 *160 * @param <T> The type of value161 * @param supplier {@link ThrowingSupplier} function that either generates the value, or throws a162 * {@link Throwable}163 * @return supplier which is refreshed for each spec's context164 */165 static <T> Supplier<T> let(final ThrowingSupplier<T> supplier) {166 LetHook<T> letHook = new LetHook<>(supplier);167 DeclarationState.instance().addHook(letHook, AppliesTo.ATOMIC_ONLY, Precedence.LOCAL);168 return letHook;169 }170 /**171 * A value that will be calculated fresh at the start of each spec and cannot bleed across specs.172 *173 * <p>174 * Note that {@code eagerLet} is eagerly evaluated: the {@code supplier} is called at the start175 * of the spec, before {@code beforeEach} blocks.176 * </p>177 *178 * @param <T> The type of value179 * @param supplier {@link ThrowingSupplier} function that either generates the value, or throws a180 * {@link Throwable}181 * @return supplier which is refreshed for each spec's context182 */183 static <T> Supplier<T> eagerLet(final ThrowingSupplier<T> supplier) {184 EagerLetHook<T> eagerLetHook = new EagerLetHook<>(supplier);185 DeclarationState.instance().addHook(eagerLetHook, AppliesTo.ATOMIC_ONLY, Precedence.LOCAL);186 return eagerLetHook;187 }188 /**189 * Define a test context. Alias for {@link #describe}.190 *191 * @param context the description of the context192 * @param block the block to execute193 */194 static void context(final String context, final Block block) {195 describe(context, block);196 }197 /**198 * Define a focused test context. Alias for {@link #fdescribe}.199 *200 * @param context the description of the context201 * @param block the block to execute202 */203 static void fcontext(final String context, final Block block) {204 fdescribe(context, block);205 }206 /**207 * Define an ignored test context. Alias for {@link #xdescribe}.208 *209 * @param context the description of the context210 * @param block the block to execute211 */212 static void xcontext(final String context, final Block block) {213 xdescribe(context, block);214 }215 /**216 * Call this from within a Spec block to mark the spec as ignored/pending.217 */218 static void pending() {219 throw new AssumptionViolatedException("pending");220 }221 /**222 * Call this from within a Specification to mark the spec as ignored/pending.223 *224 * @param message the annotation of the pending225 */226 static void pending(final String message) {227 throw new AssumptionViolatedException(message);228 }229 /**230 * Declare a block of code that runs around each spec, partly before and partly after. You must231 * call {@link com.greghaskins.spectrum.Block#run} inside this Consumer. This code is applied to232 * every spec in the current suite.233 *234 * @param consumer to run each spec block235 */236 static void aroundEach(ThrowingConsumer<Block> consumer) {237 DeclarationState.instance().addHook(Hook.from(consumer), AppliesTo.ATOMIC_ONLY,238 Precedence.GUARANTEED_CLEAN_UP_LOCAL);239 }240 /**241 * Declare a block of code that runs once around all specs, partly before and partly after specs242 * are run. You must call {@link Block#run} inside this Consumer. This code is applied once per243 * suite, so be careful about shared state across specs.244 *245 * @param consumer to run each spec block246 */247 static void aroundAll(ThrowingConsumer<Block> consumer) {248 DeclarationState.instance().addHook(Hook.from(consumer), AppliesTo.ONCE, Precedence.OUTER);249 }250}...
Source:Suite.java
...5import com.greghaskins.spectrum.internal.configuration.ConfiguredBlock;6import com.greghaskins.spectrum.internal.configuration.TaggingFilterCriteria;7import com.greghaskins.spectrum.internal.hooks.Hook;8import com.greghaskins.spectrum.internal.hooks.HookContext;9import com.greghaskins.spectrum.internal.hooks.Hooks;10import org.junit.runner.Description;11import org.junit.runner.notification.Failure;12import java.util.ArrayList;13import java.util.HashSet;14import java.util.List;15import java.util.Set;16public class Suite implements Parent, Child {17 private Hooks hooks = new Hooks();18 protected final List<Child> children = new ArrayList<>();19 private final Set<Child> focusedChildren = new HashSet<>();20 private final ChildRunner childRunner;21 private final Description description;22 private final Parent parent;23 private boolean ignored;24 private final TaggingFilterCriteria tagging;25 private BlockConfiguration configuration = BlockConfiguration.defaultConfiguration();26 private NameSanitiser nameSanitiser = new NameSanitiser();27 /**28 * The strategy for running the children within the suite.29 */30 @FunctionalInterface31 interface ChildRunner {32 void runChildren(final Suite suite, final RunReporting<Description, Failure> reporting);33 }34 public static Suite rootSuite(final Description description) {35 return new Suite(description, Parent.NONE, Suite::defaultChildRunner,36 new TaggingFilterCriteria());37 }38 /**39 * Constructs a suite.40 *41 * @param description the JUnit description42 * @param parent parent item43 * @param childRunner which child running strategy to use - this will normally be44 * {@link #defaultChildRunner(Suite, RunReporting)} which runs them all but can be45 * substituted.46 * @param taggingFilterCriteria the state of tagging inherited from the parent47 */48 protected Suite(final Description description, final Parent parent, final ChildRunner childRunner,49 final TaggingFilterCriteria taggingFilterCriteria) {50 this.description = description;51 this.parent = parent;52 this.ignored = parent.isIgnored();53 this.childRunner = childRunner;54 this.tagging = taggingFilterCriteria;55 }56 public Suite addSuite(final String name) {57 return addSuite(name, Suite::defaultChildRunner);58 }59 private Suite addSuite(final String name, final ChildRunner childRunner) {60 final Suite suite = new Suite(Description.createSuiteDescription(sanitise(name)), this, childRunner,61 this.tagging.clone());62 suite.inheritConfigurationFromParent(configuration.forChild());63 return addedToThis(suite);64 }65 private Suite addedToThis(Suite suite) {66 addChild(suite);67 return suite;68 }69 public Suite addCompositeSuite(final String name) {70 final Suite suite =71 new CompositeTest(Description.createSuiteDescription(sanitise(name)), this,72 this.tagging.clone());73 return addedToThis(suite);74 }75 public Child addSpec(final String name, final Block block) {76 final Child spec = createSpec(name, block);77 addChild(spec);78 return spec;79 }80 private Child createSpec(final String name, final Block block) {81 final Description specDescription =82 Description.createTestDescription(this.description.getClassName(), sanitise(name));83 return configuredChild(new Spec(specDescription, block, this), block);84 }85 private void inheritConfigurationFromParent(final BlockConfiguration fromParent) {86 configuration = merge(fromParent, configuration);87 }88 private Child configuredChild(final Child child, final Block block) {89 merge(this.configuration.forChild(), ConfiguredBlock.configurationFromBlock(block))90 .applyTo(child, this.tagging);91 return child;92 }93 public void applyConfigurationFromBlock(Block block) {94 this.configuration = merge(this.configuration, ConfiguredBlock.configurationFromBlock(block));95 this.configuration.applyTo(this, this.tagging);96 }97 private void addChild(final Child child) {98 this.children.add(child);99 }100 /**101 * Adds a hook to be the first one executed before the block. This is the default. Hooks should be102 * executed in the order they are declared in the test.103 *104 * @param hook to add105 */106 public void addHook(final HookContext hook) {107 this.hooks.add(hook);108 }109 private Hooks getHooksFor(final Child child) {110 Hooks allHooks = this.parent.getInheritableHooks().plus(this.hooks);111 return child.isAtomic() ? allHooks.forAtomic() : allHooks.forNonAtomic();112 }113 @Override114 public Hooks getInheritableHooks() {115 // only the atomic hooks can be used by the children of this suite,116 // all other hooks would be executed at suite level only - either for117 // each child of the suite, or once118 return this.parent.getInheritableHooks().plus(this.hooks.forAtomic());119 }120 /**121 * Set the suite to require certain tags of all tests below.122 *123 * @param tags required tags - suites must have at least one of these if any are specified124 */125 public void includeTags(final String... tags) {126 this.tagging.include(tags);127 }128 /**129 * Set the suite to exclude certain tags of all tests below.130 *131 * @param tags excluded tags - suites and specs must not have any of these if any are specified132 */133 public void excludeTags(final String... tags) {134 this.tagging.exclude(tags);135 }136 @Override137 public void focus(final Child child) {138 this.focusedChildren.add(child);139 focus();140 }141 @Override142 public void focus() {143 if (this.ignored) {144 return;145 }146 this.parent.focus(this);147 }148 @Override149 public void ignore() {150 this.ignored = true;151 }152 @Override153 public boolean isIgnored() {154 return this.ignored;155 }156 @Override157 public void run(final RunReporting<Description, Failure> reporting) {158 if (testCount() == 0) {159 reporting.fireTestIgnored(this.description);160 runChildren(reporting);161 } else {162 runSuite(reporting);163 }164 }165 private void runSuite(final RunReporting<Description, Failure> reporting) {166 if (isEffectivelyIgnored()) {167 runChildren(reporting);168 } else {169 this.hooks.once().sorted()170 .runAround(this.description, reporting, () -> runChildren(reporting));171 }172 }173 private void runChildren(final RunReporting<Description, Failure> reporting) {174 this.childRunner.runChildren(this, reporting);175 }176 protected void runChild(final Child child, final RunReporting<Description, Failure> reporting) {177 if (child.isEffectivelyIgnored()) {178 // running the child will make it act ignored179 child.run(reporting);180 } else if (childIsNotInFocus(child)) {181 reporting.fireTestIgnored(child.getDescription());182 } else {183 addLeafHook(this.hooks.forThisLevel().sorted(), child).runAround(child.getDescription(), reporting,184 () -> runChildWithHooks(child, reporting));185 }186 }187 private boolean childIsNotInFocus(Child child) {188 return !this.focusedChildren.isEmpty() && !this.focusedChildren.contains(child);189 }190 private void runChildWithHooks(final Child child, final RunReporting<Description, Failure> reporting) {191 getHooksFor(child).sorted().runAround(child.getDescription(), reporting,192 () -> child.run(reporting));193 }194 private Hooks addLeafHook(final Hooks hooks, final Child child) {195 if (child.isLeaf()) {196 hooks.add(testNotifier());197 }198 return hooks;199 }200 private HookContext testNotifier() {201 return new HookContext(testNotificationHook(), 0, HookContext.AppliesTo.ONCE,202 HookContext.Precedence.ROOT);203 }204 private Hook testNotificationHook() {205 return (description, notifier, block) -> {206 notifier.fireTestStarted(description);207 try {208 block.run();...
Source:Spec.java
1package com.greghaskins.spectrum.internal;2import com.greghaskins.spectrum.Block;3import com.greghaskins.spectrum.internal.hooks.Hook;4import com.greghaskins.spectrum.internal.hooks.HookContext;5import com.greghaskins.spectrum.internal.hooks.Hooks;6import com.greghaskins.spectrum.internal.hooks.NonReportingHook;7import org.junit.runner.Description;8import org.junit.runner.notification.Failure;9final class Spec implements LeafChild {10 private final Block block;11 private final Description description;12 private final Parent parent;13 private boolean ignored = false;14 private Hooks leafHooks = new Hooks();15 Spec(final Description description, final Block block, final Parent parent) {16 this.description = description;17 this.block = block;18 this.parent = parent;19 this.ignored = parent.isIgnored();20 }21 @Override22 public Description getDescription() {23 return this.description;24 }25 @Override26 public void run(final RunReporting<Description, Failure> notifier) {27 if (this.ignored) {28 notifier.fireTestIgnored(this.description);29 return;30 }31 // apply leaf hooks around the inner block32 leafHooks.sorted().runAround(this.description, notifier, block);33 }34 @Override35 public int testCount() {36 return 1;37 }38 @Override39 public void focus() {40 if (this.ignored) {41 return;42 }43 this.parent.focus(this);44 }45 @Override46 public void ignore() {47 this.ignored = true;48 }49 @Override50 public boolean isAtomic() {51 return true;52 }53 @Override54 public boolean isLeaf() {55 return true;56 }57 @Override58 public boolean isEffectivelyIgnored() {59 return ignored;60 }61 @Override62 public void addLeafHook(NonReportingHook leafHook, HookContext.Precedence precedence) {63 // hooks at this level are always at the same point in the hierarchy and applying to each child64 leafHooks.add(new HookContext(leafHook, 0, HookContext.AppliesTo.EACH_CHILD, precedence));65 }66}...
Hooks
Using AI Code Generation
1package com.greghaskins.spectrum.internal;2import com.greghaskins.spectrum.Spectrum;3import java.util.function.Consumer;4public class Spec {5 public static void beforeAll(Consumer<Spectrum> consumer) {6 beforeAll(consumer::accept);7 }8 public static void beforeAll(Runnable runnable) {9 beforeAll(it -> runnable.run());10 }11 public static void beforeAll(Consumer<Spectrum> consumer, int priority) {12 beforeAll(consumer::accept, priority);13 }14 public static void beforeAll(Runnable runnable, int priority) {15 beforeAll(it -> runnable.run(), priority);16 }17 public static void beforeEach(Consumer<Spectrum> consumer) {18 beforeEach(consumer::accept);19 }20 public static void beforeEach(Runnable runnable) {21 beforeEach(it -> runnable.run());22 }23 public static void beforeEach(Consumer<Spectrum> consumer, int priority) {24 beforeEach(consumer::accept, priority);25 }26 public static void beforeEach(Runnable runnable, int priority) {27 beforeEach(it -> runnable.run(), priority);28 }29 public static void afterAll(Consumer<Spectrum> consumer) {30 afterAll(consumer::accept);31 }32 public static void afterAll(Runnable runnable) {33 afterAll(it -> runnable.run());34 }35 public static void afterAll(Consumer<Spectrum> consumer, int priority) {36 afterAll(consumer::accept, priority);37 }38 public static void afterAll(Runnable runnable, int priority) {39 afterAll(it -> runnable.run(), priority);40 }41 public static void afterEach(Consumer<Spectrum> consumer) {42 afterEach(consumer::accept);43 }44 public static void afterEach(Runnable runnable) {45 afterEach(it -> runnable.run());46 }47 public static void afterEach(Consumer<Spectrum> consumer, int priority) {48 afterEach(consumer::accept, priority);49 }50 public static void afterEach(Runnable runnable, int priority) {51 afterEach(it -> runnable.run(), priority);52 }53 public static void describe(String description, Runnable runnable) {54 describe(description, it -> runnable.run());55 }56 public static void describe(String description, Consumer<Spectrum> consumer) {57 describe(description, consumer, 0);58 }59 public static void describe(String description, Consumer<Spectrum> consumer, int priority) {60 describe(description, consumer, priority, null);61 }
Hooks
Using AI Code Generation
1import com.greghaskins.spectrum.internal.Spec;2import org.junit.Test;3public class 1 {4 public static void main(String[] args) {5 System.out.println(Spec.getTestName());6 }7}
Hooks
Using AI Code Generation
1package com.greghaskins.spectrum.internal;2import com.greghaskins.spectrum.internal.hooks.Hook;3import com.greghaskins.spectrum.internal.hooks.HookContext;4import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextBuilder;5import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextBuilder.HookContextBuilderImpl;6import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl;7import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder;8import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl;9import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl.HookContextImplBuilderImplImpl;10import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl.HookContextImplBuilderImplImpl.HookContextImplBuilderImplImplImpl;11import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl.HookContextImplBuilderImplImpl.HookContextImplBuilderImplImplImpl.HookContextImplBuilderImplImplImplImpl;12import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl.HookContextImplBuilderImplImpl.HookContextImplBuilderImplImplImpl.HookContextImplBuilderImplImplImplImpl.HookContextImplBuilderImplImplImplImplImpl;13import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl.HookContextImplBuilderImplImpl.HookContextImplBuilderImplImplImpl.HookContextImplBuilderImplImplImplImpl.HookContextImplBuilderImplImplImplImplImpl.HookContextImplBuilderImplImplImplImplImplImpl;14import com.greghaskins.spectrum.internal.hooks.HookContext.HookContextImpl.HookContextImplBuilder.HookContextImplBuilderImpl.HookContextImplBuilderImplImpl.HookContextImpl
Hooks
Using AI Code Generation
1package com.test;2import com.greghaskins.spectrum.*;3import org.junit.runner.*;4public class Main {5 public static void main(String[] args) {6 System.out.println("Hello World!");7 Runner runner = Runner.forClass(Spec.class);8 runner.run();9 }10}11package com.greghaskins.spectrum;12import com.greghaskins.spectrum.internal.*;13import java.util.*;14import java.util.function.*;15import org.junit.runner.*;16public class Spec {17 private static final ThreadLocal<Deque<Context>> contexts = new ThreadLocal<Deque<Context>>() {18 protected Deque<Context> initialValue() {19 return new ArrayDeque<>();20 }21 };22 public static void describe(String description, Runnable block) {23 Context currentContext = contexts.get().peek();24 Context newContext = new Context(description, currentContext);25 contexts.get().push(newContext);26 block.run();27 contexts.get().pop();28 }29 public static void it(String description, Runnable block) {30 Context currentContext = contexts.get().peek();31 currentContext.addExample(new Example(description, block));32 }33 public static void beforeAll(Runnable block) {34 Context currentContext = contexts.get().peek();35 currentContext.setBeforeAll(block);36 }37 public static void beforeEach(Runnable block) {38 Context currentContext = contexts.get().peek();39 currentContext.setBeforeEach(block);40 }41 public static void afterAll(Runnable block) {42 Context currentContext = contexts.get().peek();43 currentContext.setAfterAll(block);44 }45 public static void afterEach(Runnable block) {46 Context currentContext = contexts.get().peek();47 currentContext.setAfterEach(block);48 }49 public static void before(Runnable block) {50 Context currentContext = contexts.get().peek();51 currentContext.setBefore(block);52 }53 public static void after(Runnable block) {54 Context currentContext = contexts.get().peek();55 currentContext.setAfter(block);56 }57 public static void xdescribe(String description, Runnable block) {58 Context currentContext = contexts.get().peek();59 Context newContext = new Context(description, currentContext);60 currentContext.addDisabledContext(newContext);61 }62 public static void xit(String description, Runnable block) {63 Context currentContext = contexts.get().peek();64 Example example = new Example(description, block);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!