当前位置: 动力学知识库 > 问答 > 编程问答 >

NUnit Testing for Asp.Net Web Application

问题描述:

I am bit confused about N-Unit Framework Testing. Below is my scenario for Web Application.

  1. Create a Ticket
  2. Assign a Ticket to User
  3. Either User can work on Ticket or He may forward it for manager Approval.
  4. Once Manager is Approved, he will work on that Ticket.
  5. Close the Ticket.

How to create test case in N-Unit Framework. Below are my few questions.

  1. Should i write code to create a Ticket? Can we insert a data to Database using N-Unit Framework.

  2. If ticket is created, should we capture that ticket number and assign it to some user.

  3. Should we write a code to assign it to user for approval?

I am not sure how to write N-Unit scripts for Wrokflow Logic.

网友答案:

When you write unit tests you usually write them so that they test one thing only. When testing a workflow you would typically split it up in several unit tests. In your scenario each point is a good candidate for a unit test except for number 3 that should be split up into at least two tests.

  1. Should i write code to create a Ticket? Can we insert a data to Database using N-Unit Framework.

It depends on your implementation. If you need a ticket for your tests then you have to create it first. No, you cannot use the NUnit framework to insert data into the database. That is not the kind of problem that the framework is intended to solve. Typically when writing unit tests you want to avoid accessing external resources like a database so try to write the code so that you don’t have to do that.

  1. If ticket is created, should we capture that ticket number and assign it to some user.
  2. Should we write a code to assign it to user for approval?

This depends on how you have implemented the system. If you need this to run your tests, then yes.

分享给朋友:
您可能感兴趣的文章:
随机阅读: