Posts Tagged ‘Automatic test’

Write (arrange) Act and Assert in your automatic tests

November 14th, 2020

It is a good custom to write out Act and Assert in test as it helps to write the test in a clean way; and helps the next reader to understand where Arrange stops and Act begins. It helps the writer to not involuntarily write Act statements in Assert.
Like so:

sut = setup()

// Act.

// Assert.

The above code is too simple to make the upside of this coding standard visible but soon tests get a few lines long and commentning Act and Assert is a good idea.

I don’t bother to write out // Arrange any more as all tests start with Arrange anyway.

Well… that was not true. I have stumbled upon tests with several Arrange, Act and Assert in them. Typically for integration tests.

Unit tests, TDD, BDD

November 28th, 2011

Maybe we shouldn’t think of unit tests, TDD or BDD but more of go no go tests. Whatever you automatically test it has a Go/NoGo, Yes/No, Success/Fail result.