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

Black box tests on Tomty #30

Closed
wants to merge 2 commits into from
Closed

Black box tests on Tomty #30

wants to merge 2 commits into from

Conversation

melezhik
Copy link

@melezhik melezhik commented Jun 13, 2020

Hi! the idea is to have end user tests via black box tests.

The additional advantage is testing
infrastructure is fully integrated into RakuDist and no efforts are required to spin up
test environment (but you could run tests locally if you need too).

I know current unit tests could achieve pretty
much the same, at least at this simple
case - run ake and parse an output ...

But again idea is to have tests
decoupled from implementation. And there are
other cases where unit tests are not
the best choice.

Anyway, take it or leave it 😀

It"s just a thoughts and maybe it could be
somehow useful ...

I'd aporeatite your feedback.

@melezhik
Copy link
Author

I forgot to attach a link to RakuDist build.

http://rakudist.raku.org/sparky/report/debian/315

@melezhik melezhik changed the title Black box testing for acke runs as RakuDist Black box testing for ake runs as RakuDist build Jun 13, 2020
@AlexDaniel
Copy link
Member

I really don't understand how this is any better than black box tests that we already have: https://github.com/Raku/ake/tree/master/t. In fact, it looks worse to me because there are so many files? I don't understand, sorry.

@melezhik
Copy link
Author

melezhik commented Jun 14, 2020

@AlexDaniel this is a very Sparrow design. You wrote tests on the language that is closest to domain ( shell because this is how people normally would run Ake scripts ), you parse stdout using check files ( optional step ), you orchestrate tests using Raku. Yeah there are more files in average in comparison to unit tests approach, but you have pure back testing.

As result:

Those tests are much easier to maintain, they are just simpler, they are 100 black box ( 'master/t' are not because they are coupled with implementation ) and they test everything from end user prospective.

@AlexDaniel
Copy link
Member

'master/t' are not because they are coupled with implementation

Look at them:

ake/t/21-tasks.t

Lines 9 to 12 in a598347

given make-ake-directory task ‘foo’, { put ‘hello’ } {
test-run simple task,
<ake foo>, :out(hello\n)
}

It dumps the given string into a file named “Akefile”, then it runs ake foo and checks the output. I don't see how you can get more black box than this, and I see nothing that needs to be improved.

@melezhik
Copy link
Author

They are coupled with an implementation in a sense you use suplimetal methods to run Ake task. Even this simple example you reference has make-ake-directory and test-run functions. it's OK, but it's extra code. Chances are with more complex scenarios you eventually add more layers. Again it's OK for unit tests where you try to test inner structure of a code. But is it OK for black box testing? This is a question.

With Sparrow you almost always get more simple and more closer to an end user approach. Just get an Ake file and get it run as a shell script. There is no even difference between Sparrow task ( shell script ) and Ake scenario gets run as a shell script. They are the same. Sparrow framework just adds some validation logic out of the box.

@AlexDaniel
Copy link
Member

Even this simple example you reference has make-ake-directory and test-run functions

They're not part of the implementation, but part of the tests: https://github.com/Raku/ake/blob/master/t/lib/AkeTester.rakumod. I hope we can agree that 34 lines of code is not a lot. And with these 34 lines I have full control of how these tests are done.

But is it OK for black box testing? This is a question.

Yes.

and Ake scenario gets run as a shell script. They are the same.

No, shell is completely avoided here, which is good.

@AlexDaniel
Copy link
Member

Just to clarify, there are probably bigger projects where Sparrow can indeed be very useful, but Ake is not one of them. I really fail to find any justification for changing the way tests are done here.

@melezhik
Copy link
Author

hi Alex. NP. i'm just testing a water and any feedback is ok.

@AlexDaniel
Copy link
Member

AlexDaniel commented Jun 14, 2020

@melezhik I think Sparrow needs a way to write single-file tests or even to pack more than one test into a single file. This is an approach that's taken by some modern projects. For example, see Vue.js (it's different, but it's a good example how different files that define a singe thing can be grouped into one file). Without this users are forced to split their tests across many files, which makes everything just messy and hard to follow.

@melezhik
Copy link
Author

melezhik commented Jun 14, 2020

yeah. the thing is Sparrow is not a testing framework ( though it has testing framework features). it's an automation framework that effectively glues various languages into Raku high level scenarios. one can always have a list of tasks in one Raku file.

i understand you concern about having more then one file, still don't see it messy.
it's just a separation for different types of entities - check files, tasks ( primitives) and high level Raku scenarios.

@niner
Copy link

niner commented Jun 14, 2020 via email

@melezhik
Copy link
Author

melezhik commented Jun 14, 2020

hi @niner i never said replacement. i am suggesting one more way to test it with some possible benefits. both solutions could coexist in parallel.

@melezhik melezhik changed the title Black box testing for ake runs as RakuDist build Black box tests on Tomty Jul 15, 2021
@JJ
Copy link
Contributor

JJ commented Jun 27, 2022

Is this still relevant? Should we merge it?

@melezhik
Copy link
Author

@JJ i will probably add tomty support to sparkyci so these tests could be run additionally to standard unit tests …

@JJ
Copy link
Contributor

JJ commented Jun 28, 2022 via email

@melezhik
Copy link
Author

Yes

@JJ JJ closed this Jun 28, 2022
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

Successfully merging this pull request may close these issues.

4 participants