質問

Using the Arrange Act Assert what should be in the Arrange "section" considering that this is an integration test on my database?

private void Delete_Release_Test_Data(string conString)
        {
            UnitTestHelper.PrepareData(new[] { "ReleaseId" }, new object[] { 100 });
            UnitTestHelper.InsertPreparedData(conString, RELEASE_TABLE);
        }

        [Test]
        public void Delete_Release(string conString)
        {
            Delete_Release_Test_Data(conString);

            // ARRANGE
            // What should I put here ???

            // ACT
            IReleaseDataProvider provider = new ReleaseDataProvider();
            provider.DeleteRelease(100);

            // ASSERT
            Assert.IsTrue(UnitTestHelper.HasNoData(conString, string.Format("SELECT * FROM {0}", RELEASE_TABLE)));
        }
役に立ちましたか?

解決

Is there a specific reason why the first line Delete_Release_Test_Data(conString) isn't under arrange? From this link on Arrange Act Assert:

Each method should group these functional sections, separated by blank lines:

  1. Arrange all necessary preconditions and inputs.
  2. Act on the object or method under test.
  3. Assert that the expected results have occurred.

Inserting valid test data is a precondition of this test which means that it should be placed under the Arrange section.

Note: You can also rename this test to Delete_Release_When_Exists and then also create a test Delete_Release_When_Doesnt_Exist to verify the correct exception is thrown or return value is correct.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top