Unit testy | Act vs Assert

0

Cześć szybkie pytanie, jeżeli wykorzystuje Assert.Throws by uzyskać wyjątek to zaliczam to do Act, czy mam tak naprawdę połączony Act & Assert ```

        [Fact]
        public void setDescription_should_thrown_exception_when_description_is_null()
        {
            // Arrange
            string expectedDescription = null;
            var expectedExMsg = "Description cannot be empty";

            // Act
            var ex = Assert.Throws<ArgumentException>(() => _author.SetDescription(expectedDescription));
            
            // Assert
            ex.Message.Should().BeEquivalentTo(expectedExMsg);
        }

VS

        [Fact]
        public void setDescription_should_thrown_exception_when_description_is_null()
        {
            // Arrange
            string expectedDescription = null;
            var expectedExMsg = "Description cannot be empty";

            // Act & Assert
            var ex = Assert.Throws<ArgumentException>(() => _author.SetDescription(expectedDescription));        
            ex.Message.Should().BeEquivalentTo(expectedExMsg);
        }
1

Ja robię to drugie, ale nie wydaje mi się, żeby miało to jakiekolwiek znaczenie.

0

Po co w ogóle pisać te komentarze Act, Assert, Arrange? Przecież z daleka widać, co jest czym.

1 użytkowników online, w tym zalogowanych: 0, gości: 1