Unit Testing without Assertions

后端 未结 14 2306
夕颜
夕颜 2020-12-17 08:35

Occasionally I come accross a unit test that doesn\'t Assert anything. The particular example I came across this morning was testing that a log file got written to when a co

14条回答
  •  隐瞒了意图╮
    2020-12-17 08:44

    This would be the official way to do it:

    // Act
    Exception ex = Record.Exception(() => someCode());
    
    // Assert
    Assert.Null(ex);
    

提交回复
热议问题