Code Monkey home page Code Monkey logo

ember-exam's Introduction

Ember Exam

Build Status NPM Version Ember Observer Score

Ember Exam is an addon to allow you more control over how you run your tests when used in conjunction with ember-qunit. It provides the ability to randomize, split, parallelize, and load-balance your test suite by adding a more robust CLI command.

It started as a way to help reduce flaky tests and encourage healthy test driven development. It's like Head & Shoulders for your tests!

Introduction to Ember Exam

The documentation website contains examples and API information.

Table of Contents

Compatibility

  • Ember.js v4.8 or above
  • Ember CLI v4.8 or above
  • Node.js v18 or above

Installation

Installation is as easy as running:

$ ember install ember-exam

How To Use

Using Ember Exam is fairly straightforward as it extends directly from the default Ember-CLI test command. So, by default, it will work exactly the same as ember test.

$ ember exam
$ ember exam --filter='acceptance'
$ ember exam --server
$ ember exam --load-balance --parallel=1

For more information and examples, please visit the documentation website.

# A value of filter is acceptance
$ ember exam --filter 'acceptance'

# A value of parallel is 2
$ ember exam --load-balance --parallel=2 --server

# If a `=` is not used to pass a value to an option that requires a value, it will take anything passed after a space as it's value
# In this instance, the value of parallel is --server
$ ember exam --load-balance --parallel --server

The idea is that you can replace ember test with ember exam and never look back.

To get the unique features of Ember Exam (described in-depth below), you will need to replace the use of start() from ember-qunit in test-helper.js with start() from ember-exam:

// test-helper.js
import start from 'ember-exam/test-support/start';

// Options passed to `start` will be passed-through to ember-qunit
start();

Version < 3.0.0

Prior to 2.1.0, Ember Exam must be loaded by importing addon-test-support/load.js and calling loadEmberExam:

// test-helper.js
import loadEmberExam from 'ember-exam/test-support/load';

loadEmberExam();

Randomization

$ ember exam --random[=<seed>]

The random option allows you to randomize the order in which your tests run. You can optionally specify a "seed" value from which to randomize your tests in order to reproduce results. The seed can be any string value. Regardless of whether you specify a seed or not, Ember Exam will log the seed value used for the randomization at the beginning of the test run:

$ ember exam --random
$ Randomizing tests with seed: liv5d1ixkco6qlatl6o7mbo6r

$ ember exam --random=this_is1337
$ Randomizing tests with seed: this_is1337

If you use random without specifying a seed, it must be the last argument you pass. Otherwise, Ember Exam will attempt to interpret any following arguments as the seed value. In other words:

# don't do this
ember exam --random --split=2
Randomizing tests with seed: --split=2 # this is not what we wanted

# do this instead
ember exam --split=2 --random
Randomizing tests with seed: hwr74nkk55vzpvi

_Note: You must be using QUnit version 1.23.0 or greater for this feature to work properly.

Randomization Iterator

Randomization can be helpful for identifying non-atomic or order-dependent tests. To that end, Ember Exam provides an iterator to make it easy to test lots of variations in your test suite order quickly.

$ ember exam:iterate <num>

This command will build your application once, and then run the test suite with the random option for the specified number of iterations. You can optionally skip the build by using a previous build via the path option:

$ ember exam:iterate <num> --path <build-path>

Finally, you can pass additional options through to the exam command used to run the tests via the options flag:

$ ember exam:iterate <num> --options <options>

The options should be a string matching what you would use via the CLI.

Generating Module Metadata File For Test Execution

$ ember exam --write-module-metadata-file
$ ember exam --wmmf

The --write-module-metadata-file, wmmf as an alias, allows you to generate a module metadata file after a test run. The file provides metadata about the test modules executed.

It creates a json file, module-metadata-<timestamp>.json, which contains an array of elements representing metadata of modules executed by sorted by ascending order:

[
  {
    "moduleName": "Module-name",
    "total": "Total number of tests in the module",
    "passed": "A number of passed tests in the module",
    "failed": "A number of failed tests in the module",
    "skipped": "A number of skipped tests in the module",
    "duration": "ms in Total duration to execute the module",
    "failedTests": "A list of failed tests"
  }
]

and it looks something like below:

[
  {
    "moduleName": "Slowest-module",
    "total": 12,
    "passed": 9,
    "failed": 1,
    "skipped": 2,
    "duration": 153,
    "failedTests": ["failed-test-1"]
  },
  {
    "moduleName": "Fastest-module",
    "total": 2,
    "passed": 1,
    "failed": 0,
    "skipped": 0,
    "duration": 123,
    "failedTests": []
  }
]

Splitting

$ ember exam --split=<num>

The split option allows you to specify the number of partitions greater than one to spread your tests across. Ember Exam will then proceed to run the first batch of tests.

$ ember exam --split=<num> --partition=<num>

The partition option allows you to specify which test group to run after using the split option. It is one-indexed, so if you specify a split of 3, the last group you could run is 3 as well. You can also run multiple partitions, e.g.:

$ ember exam --split=4 --partition=1 --partition=2

_Note: Ember Exam splits tests by modifying the ember-qunit's TestLoader to bucket each test file into a partition, where each partition has an even number of test files. This makes it possible to have unbalanced partitions. To run your tests with balanced partitions, consider using --load-balance. For more info, see Test Load Balancing.

Split Test Parallelization

$ ember exam --split=<num> --parallel

The parallel option allows you to run your split tests across multiple test pages in parallel in Testem. It will use a separate browser instance for each group of tests. So, if you specify a split of 3, then 3 browser instances will be spawned with the output looking something like:

ok 1 PhantomJS 1.9 - Exam Partition 1 - some test
ok 2 PhantomJS 1.9 - Exam Partition 3 - some other other test
ok 3 PhantomJS 1.9 - Exam Partition 2 - some other test

You can also combine the parallel option with the partition option to split tests, and then recombine partitions into parallel runs. This would, for example, allow you to run tests in multiple CI containers and have each CI container parallelize its list of tests.

For example, if you wanted to run your tests across two containers, but have one of them run twice as many tests as the other, and run them in parallel, you could do this:

# container 1
ember exam --split=3 --partition=1,2 --parallel
# container 2
ember exam --split=3 --partition=3 --parallel

Note 1: Ember Exam will respect the parallel setting of your Testem config file while running tests in parallel. The default value for parallel in Testem is 1, which means you'll need a non-default value to actually see parallel behavior.

Note 2: Ember Exam sets process.env.EMBER_EXAM_SPLIT_COUNT for convenience. You can use this in your Testem file.

Note 3: You must be using Testem version 1.5.0 or greater for this feature to work properly.

Filtering

Ember Exam provides options to filter test suites by two types - module path and test file path.

$ ember exam --module-path=<module-path>

The module-path option allows you to filter module paths by a given value. Module paths are mapped by test files and they are generated during ember build. After the build, tests.js file is created and it resides under /assets. The file is combined of all tests in an application and it has a form of define("<module-path>", others...

The value for module-path can have either string or regular expression, for instance:

# When module path value is string. This will run all modules which match with the passed value
$ ember exam --module-path='dummy/tests/helpers/module-for-acceptance'

# When module path value is regex. This will run all modules which have `dummy` in it
$ ember exam --module-path='!/dummy/'

The file-path option is to filter tests by test file path. The test file path is a location of the test file in a file system. You can specify file-path to a location of specific test file path or you can use wildcards in paths to target multiple test files.

# This will run tests that are defined in `/my-application/tests/unit/my-test.js`
$ ember exam --file-path='/my-application/tests/unit/my-test.js'

# This will run all test files that are under `/my-application/tests/unit/`
$ ember exam --file-path='/my-application/tests/unit/*.js'

Test Load Balancing

$ ember exam --parallel=<num> --load-balance

The load-balance option allows you to load balance test files against multiple browsers. It will order the test files by test types, e.g. acceptance | integration | unit, and load balance the ordered test files between the browsers dynamically rather than statically. Note: parallel must be used along with load-balance to specify a number of browser(s)

The load-balance option was added to version 1.1 to address execution performance when running against a large test suite.

Web browsers and the testem server communicate via promise in order to send and receive test file. The promise timeout value is set to 15 seconds, and is configurable by adding asyncTimeout=[timeout] as a querystring param in the test URL or adding to the test_page option in the testem config. For example, if you specify load-balance and parallel equals 3, then three browser instances will be created and the output will look something like:

# ember exam --parallel=3 --load-balance
ok 1 Chrome 66.0 - Browser Id 1 - some test
ok 2 Chrome 66.0 - Browser Id 2 - some another test
ok 3 Chrome 66.0 - Browser Id 3 - some the other test

You can also specify the split and partition options with load-balance to load a portion of test modules on multiple CI containers.

$ ember exam --split=<num> --partition=<num> --parallel=<num> --load-balance

This command will split test files and load-balance tests from the specified partition across the browsers. For example ember exam --split=2 --partition=1 --parallel=3 --load-balance, the complete list of test files are split into two halves. With the first half of the list load balanced against three browsers. The output will look something like below:

# ember exam --split=2 --partition=1 --parallel=3 --load-balance
ok 1 Chrome 66.0 - Exam Partition 1 - browser Id 1 - some test
ok 2 Chrome 66.0 - Exam Partition 1 - browser Id 2 - another test
ok 3 Chrome 66.0 - Exam Partition 1 - browser Id 3 - some the other test

Important information on Load Balancing

  1. The --load-balance option is currently only supported in CI mode and for that reason no-launch cannot be used with load-balance.
  2. You must be using ember-cli version 3.2.0 or greater for load balancing and test failure reproduction features to work properly.
  3. You must be using ember-qunit version 4.1.1 or greater for this feature to work properly.
  4. You must be using qunit version 2.13.0 or greater for this feature to work properly.
Test Failure Reproduction

Due to the dynamic nature of the load-balance option, test file execution order can vary between runs. In order to reproduce a past test execution, the execution must be recorded via passing --write-execution-file or --wef, which allows generating a JSON file that enables rerunning the past test execution. The option is only allowed when load-balance is passed.

# The command will load in test balanced mode with <num> of browser(s). After the test suite execution, it will generate a test-execution json file.
$ ember exam --parallel=<num> --load-balance --wef
$ ember exam --parallel=<num> --load-balance --write-execution-file

The file is stored in the root directory and the naming structure is test-execution-<timestamp>.json. To replay the test execution for particular browser(s), do the following:

# The command will read a test execution file specified for `replay-execution` and execute a browser Id(s) from `replay-browser`
$ ember exam --replay-execution=[string] --replay-browser=[num]

replay-execution allows you to specify a path to the json file to run execution against and replay-browser is to specify browser ID(s) to execute.

# The command will read test-execution-000000.json and load the list of modules mapped to browserId 1
$ ember exam --replay-execution=test-execution-000000.json --replay-browser=1

The above command will read test-execution-000000.json and load the list of modules which is mapped by browser ID #1.

replay-browser can be an array of browser IDs. For instance --replay-browser=1,2 will start two browsers and execute a list of modules which were previously run by browsers #1 and #2.

# The command will read test-execution-000000.json and load the list of module mapped to browserId 1 and 2
$ ember exam --replay-execution=test-execution-000000.json --replay-browser=1,2

When replay-browser value is not specified it will execute browserId(s) read from failedBrowser in the test execution file.

# The command will read test-execution-000000.json and load the list of modules mapped to browserIds from failedBrowser in the json file.
$ ember exam --replay-execution=test-execution-000000.json

When replay-browser value is not specified and there is no value for failedBrowser in the json file it will rerun all list of modules.

# The command will read test-execution-000000.json and load the list of module mapped to all browserIds when failedBrowser is none in the json file
$ ember exam --replay-execution=test-execution-000000.json

Important information on --replay-execution and --replay-browser

  1. You must be using ember-cli version 3.2.0 or greater for load-balnce and test failure reproduction features to work properly.
  2. You must be using ember-qunit version 4.1.1 or greater for this feature to work properly.
  3. You must be using qunit version 2.8.0 or greater for this feature to work properly.

Preserve Test Name

When using --split and/or --load-balance the output will look something like:

# ember exam --split=2 --partition=1 --parallel=3 --load-balance
ok 1 Chrome 66.0 - Exam Partition 1 - browser Id 1 - some test
ok 2 Chrome 66.0 - Exam Partition 1 - browser Id 2 - another test
ok 3 Chrome 66.0 - Exam Partition 1 - browser Id 3 - some the other test

However, if you change the amount of parallelization, or randomize across partitions, the output will change for the same test, which may be an issue if you are tracking test insights over time.

# ember exam --split=2 --partition=1 --parallel=2 --load-balance
ok 1 Chrome 66.0 - Exam Partition 1 - browser Id 2 - some test
ok 2 Chrome 66.0 - Exam Partition 1 - browser Id 1 - another test
ok 3 Chrome 66.0 - Exam Partition 1 - browser Id 2 - some the other test

You can add --preserve-test-name to remove the dynamic segments of the output (partition and browser) to ensure the output test names are always the same.

# ember exam --split=2 --partition=1 --parallel=3 --load-balance --preserve-test-name
ok 1 Chrome 66.0 - some test
ok 2 Chrome 66.0 - another test
ok 3 Chrome 66.0 - some the other test

Advanced Configuration

Ember Exam does its best to allow you to run your test suite in a way that is effective for your individual needs. To that end, there are lots of advanced ways to configure your setup by integrating with other aspects of the Ember testing environment. The following sections will cover a few of the more common scenarios.

Ember Try & CI Integration

Integrating ember-exam with ember-try is remarkably easy. Define a command in your ember-try.js config that leverages the exam command:

// config/ember-try.js
module.exports = {
  command: 'ember exam --split 3 --parallel',
  // ...
};

Using environmental variables gives you flexibility in how you run your tests. For instance, you could distribute your tests across processes instead of parallelizing them by specifying a PARTITION variable in your process environment and then consuming it like so:

module.exports = {
  command: 'ember exam --split 20 --partition ' + process.env.PARTITION,
  // ...
};

If you are working with Travis CI then you can also easily set up seeded-random runs based on PR numbers. Similar to the following:

const command = [ 'ember', 'exam', '--random' ];
const pr = process.env.TRAVIS_PULL_REQUEST;

if (pr) {
  command.push(pr);
}

module.exports = {
  command: command.join(' '),
  // ...
};

You can refer to Travis' default environment variables to see what else you could possibly leverage for your test setup.

Test Suite Segmentation

Some test suites like to segment which tests run based on various facets such as type of test, feature being tested, and so on. This can be accomplished by leveraging Testem's ability to have multiple test pages:

{
  "test_page": [
    "tests/index.html?filter=acceptance",
    "tests/index.html?filter=!acceptance"
  ]
}

You can use this feature in conjunction with Ember Exam's features, which will allow you to segment your test suite but still gain benefits from randomization and splitting.

ember-exam's People

Contributors

andreyfel avatar brkn avatar cbrock avatar choheekim avatar cibernox avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar ef4 avatar ember-tomster avatar kategengler avatar mariokostelac avatar nlfurniss avatar patocallaghan avatar pgengler avatar renovate-bot avatar renovate[bot] avatar rwjblue avatar samselikoff avatar scalvert avatar sergeastapov avatar stefanpenner avatar step2yeung avatar tasha-urbancic avatar thoov avatar tniezurawski avatar trentmwillis avatar turbo87 avatar vasanth-freshworks avatar yoranbrondsema avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-exam's Issues

Expose public interface for ember-exam params?

Hey Trent,

Working on getting ember-percy to automatically discover some ember-exam settings, in order to fix parallelization bugs when using both addons together.

The bug is basically that we rely on Testem.afterTests to be called only once, to know when the tests are done. This is of course called multiple times in ember-exam land, so the Percy builds are prematurely finalized when the first partition finishes and hence miss data each build.

Our options are:

  1. Discover the ember-exam split number, so we count up and only finalize on the last one. I think we can do that via the -private getUrlParams helper:
import getUrlParams from 'ember-exam/test-support/-private/get-url-params';
getUrlParams()

...but of course this is private. Would you be comfortable exposing a public interface for something like this?

Alternatively:

  1. if ember-exam exposed its own "afterAllPartitions" hook to know when all of the test partitions are done, we could use that if we see that ember exam is enabled.

Curious about your thoughts. Thanks for this great addon!

Cannout find module rimraf

It looks like rimraf is listed as a dev dependency, but should be listed as a regular dependency. When running ember exam:iterate, it ends with

Cannot find module 'rimraf'
Error: Cannot find module 'rimraf'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at CoreObject.module.exports._cleanupBuild (/Users/xanderdumaine/Code/web-directory/node_modules/ember-exam/lib/commands/exam/iterate.js:84:18)

passing options to iterate command

Just a quick question, I used to be able to run the following:

ember exam:iterate 3 --options '---split 24 --parallel --random' but since upgrading to v0.6.2 I get the following error:

The option '--split 24 --parallel --random' is not registered with the exam:iterate command. Run `ember exam:iterate --help` for a list of supported options.

I just wanted to know if this was updated & what would be the correct way to pass these options to the iterate command.

Any help would be greatly appreciated.

Test titles are mixed up in parallel

I'm running

ember exam --split=4 --parallel --random

I have an acceptance test that fails. The test has a title visiting /someurl. In the output of ember exam there is a line

not ok 232 PhantomJS 2.1 - Exam Partition #3 - Unit | Mixin | some mixin: visiting /someurl

The test-module with the title Unit | Mixin | some mixin has no failing tests and it neither contains a test with test("visiting /someurl...., so it seems that ember exam is mixing up test module titles and tests. When running without --random there is no mixup.

Test titles are mixed up when randomised

This is somewhat of a successor to #86, though it’s happening just with randomisation and not parallelisation.

You can see an example in this travis-web log:

ok 574 Chrome 59.0 - Unit | Utility | format commit: visiting a job with a complex log

This is actually from this acceptance test, not a unit test. Other tests from that same file appear elsewhere:

ok 271 Chrome 59.0 - Acceptance | job/basic layout: visiting a job with a truncated log
…
ok 401 Chrome 59.0 - computed-limit: visiting job-view

The tests before the initial one I showed all have the same prefix:

ok 570 Chrome 59.0 - Unit | Utility | format commit: integration/components/builds-item-test.js
ok 571 Chrome 59.0 - Unit | Utility | format commit: acceptance/profile/update-hooks-test.js
ok 572 Chrome 59.0 - Unit | Utility | format commit: acceptance/repo/build-list-routes-test.js
ok 573 Chrome 59.0 - Unit | Utility | format commit: serializers/repo_v2_fallback.js

I know that you said that this is probably a QUnit issue but I’m not sure how to actually prove that. If you have any suggestions on how I can show that it’s a QUnit problem and not Ember Exam, let me know, and I can open an issue there instead!

Since this is a public repository, you can reproduce this phenomenon locally with ember exam --random=yq9pfker5xi0xnp0f2kfhia4i. If you’re interested in that and have any trouble getting it running, I can make some suggestions.

Thanks for your work on this, very useful!

Unequal number of tests in each partition

We are using the split option, however we find that the number of tests executed in each partition varies greatly. Does the splitting happen on the basis of number of tests or the number of the corresponding files? If it's the latter, it represents a problem for us since we have some files that contain a large number of tests and some which contain 2 or 3. We could still refactor our tests and create more number of files containing fewer test cases, but logically, shouldn't partitioning be done on the number of test cases?

support for code-coverage

Currently, I don't believe coverage such as ember-cli-blanket supports. This may require changes no both sides, but maybe we can track that here.

Allow --split=1

I'm having issues on appveyor with split tests in firefox. What i'm trying to accomplish is run my test suite in different browsers in parallel, so I don't need / want to split the the test suite into multiple files. Would you be open to changing ember-exam to allow this?

Confusing interaction between --parallel/--split and testem parallel option

I am confused about how --parallel interacts with the parallel option in testem.js. I have my tests running in 3 browsers (chrome, firefox, ie). Testem's parallel option works how I expect:

ember test with parallel: 1 (default) runs tests sequentially
ember test with parallel: 2 runs tests in e.g. chrome and firefox first, then iexplore afterwards
ember test with parallel: -1 runs all 3 browsers at the same time

But using ember-exam I get some unexpected behavior:

ember exam --parallel --split=3 with parallel: 1 runs tests sequentially like ember test 🤔
ember exam --parallel --split=3 with parallel: 3 uses 3 browser instances as expected
ember exam --parallel --split=3 with parallel: -1 uses 9 browser instances 🤔

Is there some circumstance where this behavior makes sense?
Maybe ember exam --split should also set the testem --parallel option?

Awesome!

I just wanted to drop a quick line to say "Great work" - I'm excited for the v1.0.0 parallel feature and realize it's not trivial. Thank you for taking this on!

[Feature request] bisect command

This is a large feature request, but it would make my life far easier, so I'll throw it out: rspec recently introduced the bisect command, which combines random ordering and seeding to find out which sequence of tests causes a failure in the random-failures situation. Obviously, we can sort of pull this off manually using ember-exam, but that's a time-consuming and error-prone process. Automating it would be amazing.

Reintroduce weighted splitting

This is a really nice feature to have so that we can help ensure the split groups are running in similar amounts of time. Unfortunately, however, it is not exactly as simple as it seems on the surface.

The TestLoader only knows about the name of the module it is loading, which means that it is unaware of any QUnit modules or tests that live within that module which makes it hard to associate a runtime number with the module.

One way to solve this issue is to load modules one-by-one. We can then use a QUnit.testDone callback to check when all tests have run and use that as the runtime for the module. Load the next module and repeat.

A couple thoughts on the above approach:

  • Since the modules must be loaded one-by-one I'm unsure if this will break assumptions of any testing setups, so we may want it to be a separate flag to run in that mode
  • Reporting the actual results and subsequently loading them in will require interfacing with Testem. The loading part needs to be investigated. It is likely that we will need to implement a custom Testem reporter (or a wrapper around the reporter).

Error: You must specify a number of files greater than 1 to split your tests across.

Trying to integrate this (without setting parallel on circle first) causes this error. However I think this is undesired as circle may only provision 1 container for you if they are being used elsewhere

You must specify a number of files greater than 1 to split your tests across.
Error: You must specify a number of files greater than 1 to split your tests across.
    at TestsOptionsValidator._getShouldSplit (/home/ubuntu/platform/node_modules/ember-exam/lib/utils/tests-options-validator.js:26:13)
    at CoreObject.module.exports.TestCommand.extend.run (/home/ubuntu/platform/node_modules/ember-exam/lib/commands/exam.js:63:23)
    at CoreObject.superWrapper [as run] (/home/ubuntu/platform/node_modules/core-object/lib/assign-properties.js:32:18)
    at CoreObject.<anonymous> (/home/ubuntu/platform/node_modules/ember-cli/lib/models/command.js:224:19)
    at tryCatch (/home/ubuntu/platform/node_modules/rsvp/dist/rsvp.js:538:12)
    at invokeCallback (/home/ubuntu/platform/node_modules/rsvp/dist/rsvp.js:553:13)
    at publish (/home/ubuntu/platform/node_modules/rsvp/dist/rsvp.js:521:7)
    at flush (/home/ubuntu/platform/node_modules/rsvp/dist/rsvp.js:2370:5)
    at _combinedTickCallback (node.js:370:9)
    at process._tickDomainCallback (node.js:425:11)

ember exam --silent --reporter "xunit" --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` > $CIRCLE_TEST_REPORTS/junit/junit.xml returned exit code 1

Here is part of my circle.yml

test:
  override:
    - mkdir -p $CIRCLE_TEST_REPORTS/junit:
        parallel: true
    - ember exam --silent --reporter "xunit" --split=$CIRCLE_NODE_TOTAL --partition=`expr $CIRCLE_NODE_INDEX + 1` > $CIRCLE_TEST_REPORTS/junit/junit.xml:
        parallel: true

Automatically run all partitions

I'm interested in this add-on because my current project has a couple hundred tests and if we just call
ember test phantomjs will crash.

I would like to use this plugin and just type:

ember exam --split=3 and have it run through all three partitions, not just the first one.

Right now it looks like i have to call:

ember exam --split=3 --partition=1
ember exam --split=3 --partition=2
ember exam --split=3 --partition=3

Is this correct? If I have to call it three times will ember build three times?

Custom Inflector Rules not respected

I've encountered (in parallel only) my custom inflector rules not being respected. I am following this pattern: https://guides.emberjs.com/v2.13.0/models/customizing-adapters/#toc_pluralization-customization

I have a model 'bars' that is uncountable that is referenced through a hasMany on 'foo'. When running the model and serializer tests for 'foo' the test fails saying:
No model was found for for 'bar'

The tests both specify needs: [ 'model:bars']

These tests do not fail when running without parallelization.

I am on:
[email protected]
[email protected]
[email protected]

Simplify feature set

After the past few months of development, some of the features here don't really make sense. In particular:

  • Distill should not be an option. The primary benefit here was to support filtering via regex, but this makes more sense at the test framework level. This was also introduced to QUnit in 1.21.
  • Randomization of individual tests should be a test framework concern. This is because ensuring tests are running appropriate hooks is more correctly done at that level.
  • Randomization of JS modules should still be done at build time (like in this addon) be a concern of the test-loader since it gives greater flexibility and less risk than modifying the AST. We shouldn't need to randomize the modules since we randomize the individual tests.
  • Test splitting should most likely be a test framework concern as it can re-order and balance tests better (since it understands the test constructs). However, an initial implementation at the module level during build time still makes some sense until then, we should split using the test loader to avoid reliance on the AST.

All that to say, the API for 1.0.0 should be simple and defer to actual test frameworks (QUnit, Mocha, etc.) to do the right thing.

[v0.4.1] Cannot read property 'push' of undefined

Hi there,

first of all thanks for this amazing addon, it's great :)

I just upgraded from 0.3.1 to 0.4.1and the tests don't run anymore but show this message instead. Poking into the source I think the cause of the error is this snippet: https://github.com/trentmwillis/ember-exam/blob/master/vendor/ember-exam/test-loader.js#L60-L78

In my tests setup I have disabled linting tests, so groups is never initialized to an array of arrays and therefore the code tries to push an object onto undefined.

Parallelization

One of the core features I hoped to introduce with this addon is parallelization of tests. There are lots of considerations that went into this, and it finally resulted in needing support from Testem.

The feature will leverage the new multiple test pages in parallel config option from Testem once it is released. So, opening this issue to make sure the updates here happen once that is available.

Test name prefix "Exam Partition #XX - " is missing on testem >= 1.16.0

Steps to reproduce:
ember new ember-quickstart && cd ember-quickstart

Update testem.js and add "parallel": -1 option.

Not necessary, but just to have some more tests:
ember generate route users && ember generate acceptance-test users

Command ember install ember-exam && ember exam --split 3 --parallel produces following output:

ok 1 PhantomJS 2.1 - Acceptance | users: visiting /users
ok 2 PhantomJS 2.1 - ESLint | app: app.js
ok 3 PhantomJS 2.1 - ESLint | app: resolver.js
ok 4 PhantomJS 2.1 - ESLint | app: router.js
ok 5 PhantomJS 2.1 - ESLint | app: routes/users.js
...

After downgrading testem via npm install [email protected] command ember exam --split 3 --parallel produces expected output:

ok 1 PhantomJS 2.1 - Exam Partition #3 - Acceptance | users: visiting /users
ok 2 PhantomJS 2.1 - Exam Partition #3 - ESLint | app: app.js
ok 3 PhantomJS 2.1 - Exam Partition #3 - ESLint | app: resolver.js
ok 4 PhantomJS 2.1 - Exam Partition #3 - ESLint | app: router.js
ok 5 PhantomJS 2.1 - Exam Partition #3 - ESLint | app: routes/users.js
...

Looks like issues is in prependPartition callback for test-result Testem event: https://github.com/trentmwillis/ember-exam/blob/master/vendor/ember-exam/test-loader.js#L35

With [email protected] it receives a test object and is able to modify it's name property.
With [email protected] it receives test-result string.

I was trying to identify what was changed in [email protected] but did not succeed: testem/testem@v1.15.0...v1.16.0

Was I looking into wrong direction?

Chrome headless support

It seems that when trying to use chrome headless I get a bunch of port already in use errors. I suspect this is because chrome headless requires you to use the command line arg --remote-debugging-port=9292. When ember exam spawns multiple browsers it must just reuse the testem config and thus the subsequent browsers cannot actually bind to the port they need.

Better feedback for [email protected] and ember-cli-qunit@4.

This switch is pretty trolling for users. We made heavy note of the requirements to call start() in ember-cli release notes, but didn't mention anything about ember-exam. I think we can probably make it a bit nicer...

I'd suggest that we create a patch release of [email protected] that uses ember-cli-version-checker to detect if the host app is using ember-cli-qunit@4 and issue a loud warning (or even error) suggesting that they need to upgrade to [email protected].

Switch partitions when running in serve mode

An idea from @runspired: When running tests with ember exam --split=n --partition=1 --serve, or something similar, it would be nice to be able to switch partitions without having to quit and restart or manually modify parameters.

Currently, Testem offers support for q to quit and enter to rerun tests, but maybe it can expose an interface to extend those controls, such that Ember Exam can offer partition switching?

Mocha support

Hey Trent, I'm curious if there is workaround or planned official for getting ember-exam to work with a Mocha test suite? Right now we simply get QUnit is not defined when trying, I wanted to ask before digging further.

Introduce randomization iterator

We should introduce a new command that runs the tests in random orderings for a certain number of iterations. This would be useful as an offline job that helps verify the stability of the given test suite.

Currently this can be approximated by building the app once and then pointing to the output as the source for the test. In pseudo-code:

ember build
for 0...N
  ember exam --path dist --split 3 --parallel --random

We should set up a simple way to invoke this (maybe ember exam:iterate <num> <pass-through options>) and report all test failures at the end.

Should probably look into seeing if we can leverage/learn from ember-try for this, as they already run test suites multiple times.

Feature Request - split acceptance tests into one split

One of the issues we're facing with using this component is that our acceptance tests call a controlled API with fixtured data. Each test builds and tears down that data. When running acceptance tests in parallel, this causes problems.

It would be great if we could run the acceptance tests in one 'split' and all our unit/integration tests in another split or splits.

Is this the kind of thing that would be useful? Or is it maybe better approached by running two ember exam commands with filtering? The issue there may be that while it's easy to filter for 'only acceptance' tests, potentially it's more difficult to filter for 'everything but acceptance tests'

`Exam Partition #undefined`, each test run twice

After the 0.4.2 release yesterday, I started noticing odd behavior during test runs in CI.

I was able to reproduce the behavior locally in a fresh [email protected] app:

❯ ember new ember-exam-test && cd ember-exam-test
❯ npm install --save [email protected]

A fresh [email protected] app should have 7 JSHint tests by default. This can be confirmed with:

❯ ember t
version: 1.13.15
ok 1 PhantomJS 2.1 - JSHint - app.js: should pass jshint
ok 2 PhantomJS 2.1 - JSHint - helpers/destroy-app.js: should pass jshint
ok 3 PhantomJS 2.1 - JSHint - helpers/module-for-acceptance.js: should pass jshint
ok 4 PhantomJS 2.1 - JSHint - helpers/resolver.js: should pass jshint
ok 5 PhantomJS 2.1 - JSHint - helpers/start-app.js: should pass jshint
ok 6 PhantomJS 2.1 - JSHint - router.js: should pass jshint
ok 7 PhantomJS 2.1 - JSHint - test-helper.js: should pass jshint

1..7
# tests 7
# pass  7
# skip  0
# fail  0

# ok

Running [email protected], however, produced unexpected and incorrect results:

❯ ember exam --split=2 --parallel
ok 1 PhantomJS 2.1 - Exam Partition #undefined - JSHint - app.js: should pass jshint
ok 2 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/destroy-app.js: should pass jshint
ok 3 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/module-for-acceptance.js: should pass jshint
ok 4 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/resolver.js: should pass jshint
ok 5 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/start-app.js: should pass jshint
ok 6 PhantomJS 2.1 - Exam Partition #undefined - JSHint - router.js: should pass jshint
ok 7 PhantomJS 2.1 - Exam Partition #undefined - JSHint - test-helper.js: should pass jshint
ok 8 PhantomJS 2.1 - Exam Partition #undefined - JSHint - app.js: should pass jshint
ok 9 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/destroy-app.js: should pass jshint
ok 10 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/module-for-acceptance.js: should pass jshint
ok 11 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/resolver.js: should pass jshint
ok 12 PhantomJS 2.1 - Exam Partition #undefined - JSHint - helpers/start-app.js: should pass jshint
ok 13 PhantomJS 2.1 - Exam Partition #undefined - JSHint - router.js: should pass jshint
ok 14 PhantomJS 2.1 - Exam Partition #undefined - JSHint - test-helper.js: should pass jshint

1..14
# tests 14
# pass  14
# skip  0
# fail  0

# ok

Notice each test is run twice, and each partition number is undefined.

Reverting back to 0.4.1, the issue no longer exists and I see the results I'd expect:

❯ npm uninstall --save ember-exam
❯ npm install --save [email protected]
❯ ember exam --split=2 --parallel
ok 1 PhantomJS 2.1 - Exam Partition #1 - JSHint - app.js: should pass jshint
ok 2 PhantomJS 2.1 - Exam Partition #1 - JSHint - helpers/module-for-acceptance.js: should pass jshint
ok 3 PhantomJS 2.1 - Exam Partition #1 - JSHint - helpers/start-app.js: should pass jshint
ok 4 PhantomJS 2.1 - Exam Partition #1 - JSHint - test-helper.js: should pass jshint
ok 5 PhantomJS 2.1 - Exam Partition #2 - JSHint - helpers/destroy-app.js: should pass jshint
ok 6 PhantomJS 2.1 - Exam Partition #2 - JSHint - helpers/resolver.js: should pass jshint
ok 7 PhantomJS 2.1 - Exam Partition #2 - JSHint - router.js: should pass jshint

1..7
# tests 7
# pass  7
# skip  0
# fail  0

# ok

I'd be happy to provide any additional information if it's helpful.

Not able to run test by ember exam in split mode.

Hi
I have installed ember exam updated ember-cli-qunit@4 and test_helper.js but I am not able to run tests in split mode using ember exam. It gives so many errors. Please suggest what could be the reason for this.

//test-helper.js
import resolver from './helpers/resolver';
import registerSelectHelper from './helpers/register-select-helper';
registerSelectHelper();
import {
setResolver,
} from 'ember-qunit';
import loadEmberExam from 'ember-exam/test-support/load';
loadEmberExam();
import { start } from 'ember-cli-qunit';
start();
window.cup_ = _;
setResolver(resolver);

//Tried
ember exam -s --split=2 --parallel
ember exam -s --split=2 --parallel --filter='acceptance'

screen shot 2017-08-18 at 10 23 47 am

screen shot 2017-08-18 at 10 25 08 am

screen shot 2017-08-18 at 10 25 39 am

Random percentage of tests

Is there a way to run a random % of tests through exam? Like for example, randomly selected 25% of the tests.

document percy support

This is not a request but an offer. I think I am the first/only person to get percy.io working with ember-exam. Here is the complete list of changes required: kellyselden/package-hint-historic-resolver#159

You may want to add it to the docs, or just close this issue and allow github issue searches to find this issue.

Parallel nested inside of partition?

I have a project that really needs refactoring, but currently has a very large number of tests that take a long time to run. I use CircleCI's parallel containers feature along with some custom code that I wrote that achieves the same effect as your partitioning. I suspect that I'm not maxing out the resources in each container, though, so what I'd love to try is partitioning my tests across containers, and then in each container parallelizing the tests in its partition.

Good idea? Silly idea? I'd probably be willing to take a crack at implementing it in a PR if you tell me if you think it's a good idea and help me figure out the API (CLI) design.

Introduce more acceptance tests

Currently, the test suite is heavily skewed towards running unit tests. Most of these are valuable, but we should add some more acceptance tests to verify that the flows the end user is seeing are also correct.

Some tests fail using --split option while using ember-i18n

Hi there,
We've been using ember-exam in our project for a while, and it's worked great. However, recently we also began using ember-i18n and have noticed that some of our tests began to fail with the following message: Error: Assertion Failed: I18n: Cannot translate when locale is null.

We usually split our tests into 5 partitions and I can reliably reproduce these failures on partitions 1 and 3. Running the tests without the --split command causes all of the tests to pass.

We configure the default locale for i18n in our config/environment.js file. We also use testem, and our testem.json file is as follows:

{
  "framework": "qunit",
  "test_page": "tests/index.html?hidepassed",
  "phantomjs_debug_port": 5001,
  "disable_watching": true,
  "launch_in_ci": [
    "PhantomJS"
  ],
  "launch_in_dev": [
    "PhantomJS",
    "Chrome"
  ],
  "proxies": {
    "/api": {
      "port": 3000,
      "host": "localhost"
    },
    "/users": {
      "port": 3000,
      "host": "localhost"
    }
  }
}

I wanted to report this here in case it's buggy behavior, but I was also hoping to see if we can diagnose and fix the issue without needing a bugfix. How does --split work? What does the process under the hood look like compared to running tests without the --split option? It seems like maybe what's going on is that our configuration options aren't "taking" to each partition, but that's just a shot in the dark since I don't know exactly how --split works.

We are running the following software versions:

ember-cli: 2.7.0
node: 7.9.0
os: darwin x64

Reuse seed value when running -serve

Is this possible? If I've found a useful seed I'd like to be able to run the test server with it, so I can debug in the browser.

Thanks for this awesome addon!

How to hide passed tests?

Hi team!

Can I use some config file (e.g. testem.js... or another..) to hide passed tests?
It will be very helpful.

Thx in advance.

Arguments not passed to ember test

Our test reporter defaults to xunit. I have a grunt task that runs:
ember test --reporter=tap however, when I switch to ember exam:
ember exam --random --reporter=tap the reporter is not sent to ember test.

For ember exam to be a "drop in replacement", I think the arguments need to be forwarded on.

// testem.js
module.exports = {
  "framework": "qunit",
  "test_page": "tests/index.html?hidepassed&dockcontainer&notifications",
  "disable_watching": true,
  "launch_in_ci": [
    "PhantomJS"
  ],
  "launch_in_dev": [
    "PhantomJS",
    "Chrome"
  ],
  "reporter": "xunit",
  "report_file": "tests/results.xml"
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.