locked
Testing web pages that rely on .aspx data? RRS feed

  • Question

  • Hi,

      I'm wondering, how do I unit test c# code that relies on web page elements (buttons, textboxes, etc..) in an .aspx file?  Could someone please give details in how this is done, becuase, as far as ASP .NET websites go, I only know how to test code behind which doesn't rely on the .aspx code. Can testing be done that use elements that are defined .aspx code?  Any links that show this in depth or resources would be great, as well as explanations to how this is done.

      Thanks,

      James

    Wednesday, May 15, 2013 10:25 PM

Answers

  • Hello,

    Thank you for your post.

    I am not very sure what code you want to test. As far as I know, unit test is used to verify if the methods in classes in Visual C#, Visual Basic and Visual C++ projects have logic errors.

    And also you can unit test ASP.NET web app/web service.

    Please see: http://msdn.microsoft.com/en-us/library/ms243399.aspx

    How to: Create an ASP.NET Unit Test

    It seems that we can’t unit test a button. But if you want to test if buttons and testboxes functions correctly, you can use Coded UI test. The coded UI test performs actions on the user interface controls for an application and verifies that the correct controls are displayed with the correct values. You can refer to this article for detailed information about code UI test:

    Verifying Code by Using Coded User Interface Tests

    You can choose what test to do based on your scenario and actual requirements.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, May 22, 2013 12:57 AM
    Thursday, May 16, 2013 7:54 AM

All replies