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

Automatically generate test skeletons #65

Closed
fregante opened this issue Mar 27, 2016 · 3 comments
Closed

Automatically generate test skeletons #65

fregante opened this issue Mar 27, 2016 · 3 comments

Comments

@fregante
Copy link

This sounds like something complex, but perhaps you have better ideas.

ava-generate-tests could generate empty tests by statically analyzing the code, maybe behaving like a coverage tool by figuring out all the ways it could be run (e.g. isCool needs to be true to go in this if statement)

It can't actually build functional tests or figure out what they're supposed to output, but it could at least provide some sort of boilerplate to manually verify.

Example input.js:

export default function (sayHello) {
    if(sayHello) {
        return 'hello';
    }
}
export function strLength (str) {
    return str.length;
}

Example generated-tests.js:

import test from 'ava';
import camelizedModuleName, {strLength} from '.';

test('return undefined',t => {
    t.same(camelizedModuleName(), undefined);
});

test('return hello', t => {
    t.same(camelizedModuleName(true), 'hello');
});

test(TBD, t => { // "TBD" would be something the dev would have to replace
    t.same(strLength(TBD), TBD);
});
@sindresorhus
Copy link
Owner

That would be really cool!

@sindresorhus sindresorhus changed the title Automatically generate tests skeletons Automatically generate test skeletons Mar 27, 2016
@Qix-
Copy link
Collaborator

Qix- commented Mar 27, 2016

This is probably the best use case for Function.length if there ever was one.

@conorhastings
Copy link

i can look into working on something like this! have a couple semi similar projects that do some code/test generation

@fregante fregante closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants