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

Name test runs #2

Open
9 tasks
CodeLenny opened this issue Jun 28, 2017 · 0 comments
Open
9 tasks

Name test runs #2

CodeLenny opened this issue Jun 28, 2017 · 0 comments

Comments

@CodeLenny
Copy link
Contributor

CodeLenny commented Jun 28, 2017

Currently the name of tests is hardcoded to a default value in AVAVerify#testBody. Once arbs have been generated, pass them to opts.title() (if opts.title is provided).

Expected usage is already in the README:

const jsc = require("jsverify");
jsc.ava = require("ava-verify");

jsc.ava({
  suite: "addition",
  title: (suite, a, b, c) => `${suite}: ${a}+${b}=${c}`,
}, [ jsc.int, jsc.int, jsc.int ], (t, a, b, c) => {
  t.plan(2);
  t.is(typeof a, "number");
  t.is(a + b, c);
});

Possible Implementation

AVAVerify#opts can already contain a title function (@param opts.title), so no changes to options are expected.

In testBody after genArbs is called (71), vals is an array of values that should be passed to the test.
If a title option is provided (and is a function), then the suite name (opts.suite) and the values (vals) should be passed to title, and the result should be stored in the suite title.

t._test is a backdoor into AVA's Test class.
Setting t._test.title should change the title of the test suite.

Write a helper function for setting the test title if it's cleaner.

  • If opts.title is a function, call opts.title(opts.suite, ...vals) after getting values from genArbs
  • Pass generated title to t._test.title to change the test name.

Example and Testing

It would be good to write a new example for the different naming options. Write examples/test-naming.js with suites that test:

  • Default naming (no suite, no title)
  • Custom suite and title
  • Custom suite, default title
  • Default suite, custom title

Make sure that each test suite will output a unique name - e.g. make sure the custom title is very distinct from the default title, so the output from the suites can be tested against.

Write a test suite for this example. See test/examples/usage/passes.js for an example.

  • Modify test/examples/helpers/run-example.js to take opts.args, a string containing additional command line arguments to the exec() command
  • Write test test/examples/test-naming/passes.js
    • Ensure that the tests pass (check the exit code)
  • Write test test/examples/test-naming/suite-names.js
    • Pass the -v flag to AVA to output the name of each test run.
    • Test that some of the suite names are output string to make sure two or three runs of each suite are properly named.
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

1 participant