Aplicaciones de subprocesos múltiples TDD
Frecuentes
Visto 703 veces
2
Could someone shed some light on how multi threaded functionality could be developed in a pure TDD fashion. (possibly with some examples in C# or Java)
Gracias de antemano.
1 Respuestas
2
En breve,
- First assert that the code that runs on a thread works. Functionality wise. Simple unit test - no threads. You can extract a type (sample name Executor) that abstracts away the threading aspect. e.g. Execute(codeblock) that spawns a new thread in production on which the codeblock is executed. In tests, codeblock is executed on the calling thread - like a function call.
- Next write a stress test that uses the production Executor. Spawn multiple threads and assert on your invariants. i.e. things that must/must not happen irrespective of how many threads are spawned.
There are some other nuances to this - based on whether you are spawning multiple threads (active) or whether you are being called on different threads (passive). I'd recommend you read up the chapter related to threading in the GOOS book by SteveFreeman and NatPryce
Respondido el 13 de junio de 12 a las 06:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas unit-testing tdd testdrivendesign or haz tu propia pregunta.