3
何时给定(GWT)和行为安排断言(AAA)之间的区别?
在TDD中,有Arrange Act Assert(AAA)语法: [Test] public void Test_ReturnItemForRefund_ReturnsStockOfBlackSweatersAsTwo_WhenOneInStockAndOneIsReturned() { //Arrange ShopStock shopStock = new ShopStock(); Item blackSweater = new Item("ID: 25"); shopStock.AddStock(blackSweater); int expectedResult = 2; Item blackSweaterToReturn = new Item("ID: 25"); //Act shopStock.ReturnItemForRefund(blackSweaterToReturn); int actualResult = shopStock.GetStock("ID: 25"); //Assert Assert.AreEqual(expectedResult, actualResult); } 在BDD中,编写测试使用类似的结构,但语法为“当下(GWT)”: [Given(@"a customer previously bought a black sweater …
13
c#
unit-testing
tdd
bdd