spectrum
spectrum copied to clipboard
[Question] How stop test?
How I can stop queue of tests in spec if one of test is fail?
describe("some spec", () -> {
it("First test", () -> {});
it("Second test", () -> { // something broken });
it("Third test", () -> {});
});
if second test will is broken, third test will not run.
@A11oW Usually, in test suites, you don't want to stop on the first failure because you want to know all of the tests that are failing.
However, if you're asking because you temporarily want to be able to run one specific test in isolation, try changing it to fit. This is referred to as "focused it". You can also use fdescribe to focus in on a specific describe block, fcontext to focus in on a specific context block, etc. If there are multiple that start with f then only those tests run.
More here: https://github.com/greghaskins/spectrum/blob/1.2.0/docs/FocusingAndIgnoring.md
Does that address your question?
@GuyPaddock Thanks for answer. Unfortunately my test have many steps, for example:
describe("Test of some kind of business case", ()-> {
context("authorize", () -> {
it("input login and password", () -> {})
});
context("Go to form 1", () -> {
it("Fill form", () -> {});
it("Check form", () -> {});
it("submit form", () -> {});
});
context("Go to form 2", () -> { ... });
...
});
I can't check form 2 without step of "authorize" and "Go to form 1", and if form 1 is fail, test of "Go to form 2" meaningless and I would like stop all next test's.
@A11oW The Gherkin DSL (given/when/then) may be helpful for your use-case. Each sub-step inside a scenario only runs if the previous step has succeeded.