Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6079055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:54:11+00:00 2026-05-23T10:54:11+00:00

i have a small web application which does some simple data io via a

  • 0

i have a small web application which does some simple data io via a gui front end.

so when the use hits ‘save’, the data is saved. On a runtime exception, i catch the exception, log it, and display a ‘sorry etc.’ label.

so as this code normally does not fail, and especially not when i want it to, there is no way for me to see if my ‘sorry’ label shows up and the ‘succesfully saved’ label is hidden.

Is there a nice solution for this?

the only way i could think of is to create a stub which throws an exception and via ioc load that stub when i want to check the ‘fail’ scenario’s.
this creates some extra work, and does not help me when i first want to test the failure of step 1, and then the succes of step 1 and the failure of step 2.

I now do it manualy with inserting (and deleting) some throw exception commands, but that of course isn’t very reliable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:54:12+00:00Added an answer on May 23, 2026 at 10:54 am

    what you should do is decouple the logic you are executing from the front end as much as possible. Then you can write a test which checks that the logic is executed properly independently of the UI.

    You could start by writing a class which takes an object representing the data to be saved and an interface representing the dependency which will do the saving (and perhaps a interface which represents the logging dependency). Then you can write tests which pass a mock dependency which is configured to throw exceptions at the correct points, and invalid data which you can check the validation of. You could also validate that the logging was performed as you expected. This class could return an object which represents the success or otherwise of the function and you could show the message or not based on that returned object. If you are using MVC then you could validate theat the correct view is returned in the case of an error instead, but if not, then you are a bit stuck with the UI logic as far as testing goes and your only real option is to make the logic there as simple as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created small test web application which makes use of LINQ to SQL.
I am thinking of making an (initially) small Web Application, which would eventually have
I have a small C# ASP.NET web application which generates several PNG image files
I have a simple idea for a small web application that I'd like to
I have developed a small C# form application which calls a web service. Everything
I have a small web application with ASP.NET AJAX running well under the Cassini
We have developed a small web application for a client. We decided on the
I'm making a small web application in Seaside. I have a login component, and
I am developing a small intranet based web application. I have YSlow installed and
I have defined small MXML component which calls web service which returns random number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.