This is a migrated thread and some comments may be shown as answers.

Are reports testable in any way?

2 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 21 Sep 2010, 06:35 PM
Is there a way to unit test reports?  To make sure they all render without errors?

Steve

2 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 15 Apr 2011, 05:50 PM
Bump* 

My team is moving towards testing heavy development and one of the things we would like to have tested is the reports. Any word on this?
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 15 Apr 2011, 06:31 PM
Try this

[TestMethod]
        public void Report_EmergEvalSummary() {
            //Main Report
            Deli.Undergrad.Reporting.Emerg.EmergEvalSummary report = new Deli.Undergrad.Reporting.Emerg.EmergEvalSummary();
            report.Error += new ErrorEventHandler(report_Error);
 
            report.ReportParameters["View"].Value = "All";
            report.ReportParameters["CampusOfAdmin"].Value = "Hamilton";
 
            RenderingResult result = new ReportProcessor().RenderReport("PDF", report, null);
        }

/// <summary>
        /// Common Error Handler
        /// </summary>
        void report_Error(object sender, ErrorEventArgs eventArgs) {
            Assert.Fail(eventArgs.Exception.ToString(), eventArgs.Exception);
        }

Renders the report to PDF and if a error exists anywhere in it, Assert.Fail is called

I think I put in a ticket about this is why this post isn't answered.
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Andrew
Top achievements
Rank 1
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or