3 ms·
> But for example, when I write a particle system, how would I test that? Do I test all combinations of parameters and then compare them with images, which tak
by je42 8y ago
> But for example, when I write a particle system, how would I test that? Do I test all combinations of parameters and then compare them with images, which takes a million years?
A couple of assumptions:
- your particle system is not one monolithic function, right ?
- you also didn't just write it in a single pass and it had all features.
So:
(i am applying the test pyramid here ( https://martinfowler.com/bliki/TestPyramid.html https://martinfowler.com/bliki/TestPyramid.html )
- you start with a very simple (system) test that describes the minimal particle system. something like: given a particle system with particle count 1 and an emitter with probability 1 and velocity (1,0,0) and random seed 0; then after 1 step, there is a exactly one particle with velocity 1,0,0 at position 0.
- and you make this test compile and run and eventually pass.
- eventually you split out different functions; you develop also a test first. and then write the new function. and then change the original large function of the particle system to use the smaller functions. :)
- when it comes to rendering, you probably never want to write a system test that renders a full blown particle system with random paratemers ( because the test will likely be unstable unless you have a good idea about to keep it stable ).
- what is easier is to take the rendering functions and let them render aspects separately, i.e it renders a single particle at a known position. and you check the rendered image if it is correct; this because pretty simple with the image resolution is for example is just a pixel or 9 and that you can compare with a single static value. color animation can be tested that way as well. etc.
- thus in general even a particle system can be tested; break the system into small functions and test them separate and fully.
- then integration test the function in concert. use stable test scenarios.
- test manually; and when you find a bug (and you will). write first a test for the simple buggy function to expose the issue on unittest level. and then you decide if you want to add an extra scenario on the high levels.