Unit Testing Group

cancel
Showing results for 
Search instead for 
Did you mean: 

Given When Then

I watched an interesting video on youtube the other day about improving unit testing practices in Java and got serious tool envy!

https://www.youtube.com/watch?v=D-xra_X9Nwg

One bit I liked was the bit about splitting tests into given-when-then statements.

This is a recommended format for acceptance test descriptions from non-technical users (e.g. given the tests stop after 20 seconds, when I resume then it starts where it left off).

This helps highlight if you are testing too much since you should only have assertions in then (ideally 1, or you are testing 1 state) and for me I think it might help tidy up my tests since you can quickly glance and identify setup (given), code under test (when) and the assertions (then).

I will likely write up a bit more detail in a blog post once I have played a bit more but was curious to get some feedback. Here is my interpretation in LabVIEW, anyone else have any better ideas?

given-when-then.jpg

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
Message 1 of 3
(6,264 Views)

Our in-house unit testing framework template.vi has a sequence structure with "Arrange / Act / Assert" which is basically the same as what you have above.

Many of the acceptance-style testing frameworks (eg. Cucumber) rely on a run-time interpreted lexical language. Such a thing would be possible in LabVIEW but I wonder about its acceptance (pun intended).

Any yes, I often get tool envy with other stacks versus LabVIEW. It just seems the demand for the tools is higher (as is the user-base).

0 Kudos
Message 2 of 3
(5,641 Views)

James_McN schrieb:

https://www.youtube.com/watch?v=D-xra_X9Nwg

"I don't write tests when I want to inflict pain on my coworkers"

Good one....

0 Kudos
Message 3 of 3
(5,641 Views)