jeudi 16 janvier 2020

How to do TDD for real time applications

I've been studying the discipline of Test Driven Development and for me it has worked well for implementing algorithms and input-output systems.

So, as far as I understand, the "essence" of TDD is to actually write tests for each requirement of the application. Normally this requirement defines a behavior with inputs and outputs.

So, now. Going to real time applications. Let´s say your application runs an infinite loop. A common example is a graphics application or an audio application where each iteration of the loop means output to the screen/speakers.

Having a system like that, let´s say the requirement is something like: "When pressing Enter button, the screen should show a circle with the text Hello World inside the circle"

So how would you test drive this kind of requirement.

Another example, just to illustrate my question better. Let´s say I´m emulating a CPU. In each iteration, I fetch an opcode from the file, translate it and execute it. Basically there is no actual output. What happens is there is input which changes some state related to the emulation of the CPU. So no public interface for the CPU internals.

My requirement would say something like "Implement the mov operation on the cpu emulator" Which may be part of the bigger requirement "Implement opcodes emulation"

So. What would be a good approach for tackling this behaviors/requirements using TDD?

Aucun commentaire:

Enregistrer un commentaire