question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement BDD interface and nested fixtures

See original GitHub issue
describe('Utils', () => {
  describe('compose', () => {
    it('composes from right to left', () => {
         ...
    });
  });
});

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:35
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gilmeir-curvcommented, Aug 5, 2020

Adding to what @inikulin reported, take for example jest, which lets you nest multiple describe sections, including each section’s hooks. See my comment here.

1reaction
chikunovcommented, Aug 3, 2020

Sure,

lets say that i have a page with a form that could be in 2 different modes: read-only and editing. As name suggests, you should switch to the edit mode before you can change any values in the form. Rendering for those is different too. I would like to have something like the following:

fixture `MyPage`
    .page `http://mypage.com`;

section
    .before(async t => {
        await t.scrollTo(form);
    })
    ('Form', async t => {
        section
            .before(() => {
                await form.switchToReadOnlyMode();
            })
            ('Read-only mode', () => {
                test();
                test();
            });

        section
            .before(() => {
                await form.switchToEditMode();
            })
            ('Edit mode', () => {
                test();
                test();
            });
    });

section("Something unrelated to form on the same page", () => {})

This allows to group tests together and have a single setup point for a group. Furthermore, it allows to apply some metadata to sections and use it in reporting afterwards

section('Some page area', () => {
  section.metadata('browser', 'chrome')("chrome tests", t => {
     test(); 
  });

  section.metadata('browser', 'firefox')("firefox tests", t => {
     test(); 
  });
})

It is possible to replicate similar behavior by moving those preparations into a separate function and calling them in every test, setting up metadata on every test etc. But this leads to a lot of duplication in code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested tests / subtests · Issue #5511 · DevExpress/testcafe
We already received an enhancement request: Implement BDD interface and nested fixtures. So I'll close this one as a duplicate.
Read more >
Features All Test Frameworks Should Have | Chad Austin
Nested fixtures allow reusing common environments across many tests. The BDD frameworks tend to support that because nested contexts are one of their ......
Read more >
Integration Testing with xUnit - Jimmy Bogard
The general idea is that fixtures must be supplied via the constructor, so I have to create a bit of a nested doll...
Read more >
BDDMockito (Mockito 3.3.3 API) - javadoc.io
public class BDDMockito extends Mockito. Behavior Driven Development style of writing tests uses //given //when //then comments as fundamental parts of your ...
Read more >
Interacting With Web Pages | Serenity BDD Users Manual
When you need to use a page object in one of your steps, you just need to declare a variable of type PageObject...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found