Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested test structures? #20

Closed
markerikson opened this issue Dec 10, 2015 · 7 comments
Closed

Nested test structures? #20

markerikson opened this issue Dec 10, 2015 · 7 comments

Comments

@markerikson
Copy link

Trying to play around with CodeceptJS, having never actually used Mocha or anything similar before. Mocha's docs seem to indicate that you can set up nested tests using describe() and it(). It looks like Codecept's Feature() and Scenario() are an alternative method to setting up Mocha's Suites. Is there a similar way to set up nested tests using CodeceptJS? For example, something vaguely like:

Feature('Test1');

Before((I) => { // or Background
  I.amOnPage('/');
});

Scenario('Interact with the login page ', (I) => {
  Feature("Test 1 - Part 1");

  Scenario("Filling in login form shows consent banner", () => {
    I.see('Username');
    I.dontSee("You are accessing");
    I.fillField("httpd_username", "user1");
    I.fillField("httpd_password", "pw1");
    I.see("You are accessing");
  });

  Feature("Test 1 - Part 2");

  Scenario('Can log in successfully', () => {
    I.see('Username');
    I.fillField("httpd_username", "user1");
    I.fillField("httpd_password", "pw1");
    I.click('Agree and Log In');
    I.wait(1);
    I.dontSee("Username");
  });
});
@DavertMik
Copy link
Contributor

Right now we don't provide any kind of nesting.
And there is no something like that in nearest plans. One feature per file for now.

@markerikson
Copy link
Author

Hmm. That's kind of disappointing, particularly since Mocha does support nesting suites.

Here's my use case. Right now, with that I.amOnPage('/'); in Before(), Codecept appears to be bringing up a separate browser instance for every test. That's taking around 15s or so to execute a test.

I'd really like to be able to use a single Webdriver / browser instance for a series of tests. Beyond that, I'd like to be able to, say, run an initial test verifying that logging in works, then run additional tests after that that require having successfully logged in.

Again, I'm very new to actual automated testing and to Codecept, but that seems like a pretty useful scenario to support.

@DavertMik
Copy link
Contributor

Here's my use case. Right now, with that I.amOnPage('/'); in Before(), Codecept appears to be bringing up a separate browser instance for every test. That's taking around 15s or so to execute a test.

Thanks for the idea. We will add option to reuse instance of a browser.

Beyond that, I'd like to be able to, say, run an initial test verifying that logging in works, then run additional tests after that that require having successfully logged in.

This concept is somehow harder to implement. As you will probably have LOTS of tests where user is logged in (and probably in different files) and one test for a login. Probably this will require something like dependency tree for tests.

But in the end, I think that you don't need nested structures for this kind of tests. Yes, mocha support them, but CodeceptJS is about scenario-driven testing so it's better to keep it linear.

@arsa666
Copy link

arsa666 commented Jan 8, 2016

Hello markerikson

I had the same issue, I hate waiting for the browser to open and close. What I did was that I created a script that concatenates many files into one and puts all my different file test into a single test all contained in the same Scenario(), this way I can test memory leaks in my app on the browser.

So far it works great. I can share you my script if you want.

@adrianblynch
Copy link
Contributor

Would be nice to see your script. I wonder how much time you're saving doing it this way?

@Nighthawk14
Copy link
Contributor

@markerikson That may interest you #167

@DavertMik
Copy link
Contributor

I think this can be closed as all helpers have restart: false option which can be used to reuse browser session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants