Given: I have a policy of writing thorough, automated unit tests for every externally visible element of an application/system.
Given: I have an API that includes accessors for a property.
The accessors look like this:
getA()::
return A
setA( a )::
A = a
Unit tests for the accessors are identical:
setATest::
exp = 0
setA( exp )
act = getA()
assert( exp == act )
getATest::
exp = 0
setA( exp )
act = getA()
assert( exp == act )
Question: as a matter of policy, should I always have a separate unit test for both accessors, or is one unit test, "testSetGetA", sufficient?