BotTester icon indicating copy to clipboard operation
BotTester copied to clipboard

[ARO] Adding a feature to make tester able to create their own test

Open erbizard opened this issue 6 years ago • 15 comments

I was unable to make UT, caus every testing command in the package.json return error. If you got any tips to start them i'm completly open to write them

erbizard avatar Jul 24 '18 15:07 erbizard

Coverage Status

Coverage increased (+0.6%) to 92.948% when pulling 1ee88fe373b768afa7ff94f92a828ed38063156c on erbizard:feature/functionTest into 26ee91527f1d48f45d5b4c22f4701ea1b0f7ae4c on microsoftly:dev.

coveralls avatar Jul 24 '18 16:07 coveralls

please add tests to the BotTester.mocha.spec and BotTesterFailure.mocha.spec.

microsoftly avatar Jul 24 '18 16:07 microsoftly

I think it would be helpful to make a unique case to assert against. For instance

botTester.sendMessageToBot('something', (message) => {
// do things

  return 'hello'
}, 'hello')

so that we know what to assert against. A bool return type could be used, but then we lose the benefit of good messaging on failures.

microsoftly avatar Jul 24 '18 16:07 microsoftly

Like I said in my first comment, I'm unable to run your test, and create test without testing them is little bit strange. λ mocha test/**/*.mocha.spec.ts --require node_modules/ts-node/register "BotTester\node_modules\ts-node\src\index.ts:307 throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset)) ^ TSError: ⨯ Unable to compile TypeScript"

maybe for your second comment, I can make a process if function return String, to make a better assert. But i still think it's good that dev can make their own error for fail the test, cause in some case string is not enough information and some tests doesn't test string (example in the README.md with the even test)

erbizard avatar Jul 25 '18 07:07 erbizard

If an error is thrown inside a test step, that step will be recorded as an error. If a dev wants to fail in their test, that approach would still work

microsoftly avatar Jul 25 '18 15:07 microsoftly

I can also assure you that the tests do work and your changes break existing functionality. Check out the CI tests -> https://circleci.com/gh/microsoftly/BotTester/242?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

microsoftly avatar Jul 25 '18 15:07 microsoftly

My last commit got some bug, you right, but i need to start your CI every time i need to test, cause your tests commands doesn't work, atm i don't know how your ci chain is defined, but on my computer your testing routing didn't lauch, after short look i've tried to make them work by changing your "ts-node": "^3.1.0" version, that got 4 majors version late, but nothing make it work.

For the return I might check soon, but i've not many time.

erbizard avatar Jul 25 '18 15:07 erbizard

Also, no existing functionality were engaged in all my commit, there's only my dev that break every time

erbizard avatar Jul 25 '18 15:07 erbizard

That error is strange considering it can transpile just fine. Can you show the error stack? What ts-node/tsc version did you pull down?

microsoftly avatar Jul 25 '18 15:07 microsoftly

You're also correct, I think one of the tests must be flaky

microsoftly avatar Jul 25 '18 15:07 microsoftly

"version": "3.3.0"

$ ./node_modules/mocha/bin/_mocha --require node_modules/ts-node/register test/**/*.mocha.spec.ts

C:\Users\arthur.rouet\Desktop\Angie-bot\BOT_Hello_Eng-master\BotTester\node_modules\ts-node\src\index.ts:307 throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset)) ^ TSError: ⨯ Unable to compile TypeScript test\mocha\chai\BotTester.mocha.spec.ts (483,13): Type '{ title: string; type: "this is no the correct type"; }[]' is not assignable to type '(ISubmitAction | IOpenUrlAction | IShowCardAction)[]'. Type '{ title: string; type: "this is no the correct type"; }' is not assignable to type 'ISubmitAction | IOpenUrlAction | IShowCardAction'. Type '{ title: string; type: "this is no the correct type"; }' is not assignable to type 'IShowCardAction'. Property 'card' is missing in type '{ title: string; type: "this is no the correct type"; }'. (2322) at getOutput (C:\Users\arthur.rouet\Desktop\Angie-bot\BOT_Hello_Eng-master\BotTester\node_modules\ts-node\src\index.ts:307:15)

erbizard avatar Jul 25 '18 15:07 erbizard

I've also thought to a upgrade for this, just return an array with [excepted,got] results, to make the assert better on this feature. that can make better than just a string, in case of check on carousel, heroCards ... etc but that can take me a little time to implement it and test it.

If you are okay with that, i can implement this before the end of the week I think.

erbizard avatar Jul 25 '18 15:07 erbizard

Are you on windows? I'd imagine that could be a source of the bug. I've not tested outside of an *nix env

microsoftly avatar Jul 25 '18 16:07 microsoftly

Yes I'm on windows

erbizard avatar Jul 26 '18 07:07 erbizard

But Unit test isn't a problem actually, I've made them and the coverage is okay. The only issue I can see her is the excepted bool to the assert that i'm going to change. When this going to be done i'll post a comment on this trend so you'll be notified.

erbizard avatar Aug 01 '18 08:08 erbizard