The general question is are there alternative patterns to AAA for unit testing? If, yes, would be very interesting to see some examples and hear about their pros and cons.
And as the simplest example of AAA test (in c#, using var for the sake of simplicity):
// Arranging
var annualSalary = 120000M;
var period = 3; // for a quarter profit
var calc = new SalaryCalculator();
// Acting
var result = calc.CalculateProfit(annualSalary, period);
// Assertion
Assert.IsEqual(40000, result);
The AAA pattern is a common unit testing pattern. It is a way to arrange and organize test code to make unit tests clear and understandable, and consists of separating each unit test method into three sections: Arrange, Act, and Assert.
The idea is to develop a unit test by following these 3 simple steps: Arrange – setup the testing objects and prepare the prerequisites for your test. Act – perform the actual work of the test. Assert – verify the result.
Authentication, authorization, and accounting (AAA) is a term for a framework for intelligently controlling access to computer resources, enforcing policies, auditing usage, and providing the information necessary to bill for services.
Abdominal aortic aneurysm (AAA) screening is a way of checking if there's a bulge or swelling in the aorta, the main blood vessel that runs from your heart down through your tummy.
I like something that is not so much an alternative to AAA, but rather a variation. I think of it as Arrange-Assert(not)-Act-Assert, but others have called it a Guard Assertion. The idea is to have an assertion that ensures the desired result of the Act is not already present before the act. There's a good discussion of it here.
There is another notation from Behavior-driven development: Given - When - Then. Examples for c# is SpecFlow and for Jasmin for JavaScript. Both resource are full of examples of using this notation. The GWT approach is typically used in a Behavior Driven Development and Aspect Oriented Programming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With