Flashcards in Test 3 Deck (20):
Explain the purpose of a code repository
A code repository is essentially a version control tool, which allows users to make changes to existing source code in real-time, and without the hassle of traditional patches that the original source owner would need to evaluate. A repository is cloned to a local machine, changes are made, then the local copy is merged with the traditional if the changes are deemed acceptable.
Creational design pattern that essentially provides an interface for creating families of related, dependent objects without specifying their concrete classes.
A structural design pattern in which a singleton is the sole means for obtaining functionality from the package.
Creational design pattern that essentially defines an interface for creating an object, but it allows subclasses to decide which class to instantiate.
A behavioral design pattern that essentially allows the definition of a family of algorithms, which are all interchangeable depending upon the client that uses them.
Explain the purpose of unit testing
Unit testing breaks an application into small, discrete, testable behaviors. This allows a developer to test these units, rather than attempting to test an entire application, which will probably have infinite paths and eventually evolve into something that cannot be appropriately tested.
Setting up the environment, making sure all preconditions are met, selecting the input data, and determining the expected result.
Applying the input data to the unit.
Comparing the actual result to the expected result.
A precondition is what is assumed to be true before the method is executed.
A postcondition is what is assumed to be true after the method is executed.
An assertion is a statement that says something about the state of the unit. Assertions should be true.
Test class using MSTest
public class ABankAccount
ShouldSetBalanceAndAnnualInterestRateWhenConstructed ( )
// Arrange, Act
var sut = new BankAccount (100.0m, 0.1m);
Assert.AreEqual (100.0m, sut.Balance);
Assert.AreEqual (0.1m, sut.AnnualInterestRate);
Ensures all statements in the unit are executed at least once by at least one test case.
Ensures all branches in the unit are executed at lease once by at least one test case.
Ensures all predicates in the unit are executed at least once by at least one test case.
All Path Coverage
Ensures that all path combinations in the unit are executed.
Explain what an equivalence partition is
Equivalence partitioning divides input values into equivalent groups. It is used to limit the number of test cases to something "reasonable."
Derive an equivalence partition from X and Y
(x and y, post), (not x and y, exception), (x and not y, exception), (not x and not y, exception)