1

Below is a sample test case which I wrote on my test suite.

In my project i need to be more focus on test reporting, so I thought in storing the test Pass / Failed status on SQL data table.

Then I can use some 3rd party tool to generate the report by referring to the SQL data table.

Any suggestions?

   [TestMethod]
        public void Validate_Availability_Of_Identity_Selector_Buttons()
        {
            string TestCaseName = "Validate Availability Of Identity Selector Buttons";
            AvailabilityElm elm = new AvailabilityElm();
            try
            {
                Assert.IsTrue(elm.IdentitySelectors.Displayed == true);

                AddtoSQL(TestCaseName,"Pass","");
            }
            catch (Exception e)
            {

                AddtoSQL(TestCaseName,"Failed",e.ToString());
            }

        }

I have used Extended report in the past but I feel I need to add more lines of codes to the test steps if I'm moving with extender reports.

This is how my SQL table looks like :

command.CommandText = "  INSERT INTO [dbo].[AUStagAdminPanelTestData]([TestcaseName],[Status],[Info])VALUES(@TestcaseName,@Status,@Info)";

closed as unclear what you're asking by IAmMilinPatel, NarendraC, Bharat Mane, Shailendra Rathore, Peter M. Feb 2 '17 at 22:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Could you clarify exactly what type of advice you are looking for? Is it a technical one (on how to use the SQL data ) or a processual one (how should you design the report)? In both cases, you should specify the target public of these reports: - The testers that write the automated suite? - "Non-techinical" QA? - Devs? - Business representatives? - A bug report tool (that will log the failures automatically)? This information interferes directly on the type of report you want. – João Farias Jan 29 '17 at 20:24
1

I have done something similar in the past, but not in the test itself. Most xUnit test-frameworks have SetUp() and CleanUp() functions. This seems a better place to handle this. Primary as you do not repeat yourself in each test-case. It will be easier to add more fields for your report when needed.

For C# and MS-test this would like something like this:

[TestInitialize]:

Instead of your example I added the test to the database in the [TestInitialize] step. [TestInitialize] is run for before each test is run. Also I included a start Timestamp field in the database.

You can use the Test.Name for the name of the test instead of hard-coded "strings"

string testMethodName = TestContext.CurrentContext.Test.Name;

[TestCleanup]:

In the [TestCleanup] I would update the record with pass/fail data, fail-count and an end-timestamp.

if (TestContext.CurrentTestOutcome.ToString() == "Failed") {
  //Do Something
}

With the timestamps you can also see how long the test takes and when they started.

Re-run:

We used this data in a script to select test-cases to re-run slow UI tests after a fail. We would re-run each test up-to three times, this because some of the tests would be flaky, but we did not want to research them everyday.

More reads:

  • \wow..I was pretty much aware about test attributes and i was wondering why i didnt use [TestCleanup] to set pass / fail data.Thanks a lot for mention it. – ChathuD Jan 30 '17 at 3:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.