Search code examples
mspec

How to group tests in MSpec?


Could you help me please with my problem.

I am working on a project. For tests I use MSpec. Is it possible to group test. So when I run test runner they should be tested by groups i.e. for proper way:

1) When registering user, I provide different password and confirmation password

  • should return error message

2) When registering user, I provide all needed information » user should be registered » user should be redirected to home page

3) When getting tags tree, I get tags tree

  • we should see tags tree

But in my case it works like:

1) When registering user, I provide different password and confirmation password

  • should return error message

3) When getting tags tree, I get tags tree

  • we should see tags tree

2) When registering user, I provide all needed information

  • user should be registered
  • user should be redirected to home page

Solution

  • The only place contexts are grouped right now is in the HTML report. You need to use the [Subject] attribute and provide the same text or type name for contexts that need to be grouped.

    On an unrelated note, I would name your contexts/specifications differently:

    User registration, When providing different password and confirmation password
      » should display an error message
    
    User registration, When providing all information needed (What's "all" information?)
      » should register the user
      » should redirect to the home page
    
    Tags tree, When getting the tags tree
      » should display the tags tree