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

  • SEARCH
  • Home
  • 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 4344056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:50:30+00:00 2026-05-21T11:50:30+00:00

I like to create my test methods like: Should_not_allow_negative_number_in_value() But it’s pretty boring to

  • 0

I like to create my test methods like:

Should_not_allow_negative_number_in_value()

But it’s pretty boring to keep typing _ every time, and it also has always the same signature…

so… anybody knows to make it faster??

thanks!

  • 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-21T11:50:31+00:00Added an answer on May 21, 2026 at 11:50 am

    Something that might automate (not at all, but a little more if you use this naming notation) this process:

    I usually name my tests like this:

    MethodToTest_State_ExpectedBehavior

    Example:

    [Test]
    public void ConvertToInt32_NullValue_ThrowException
    {
        //Test method body
    }
    

    You can install ReSharper, and create a new Live Template like:

    [Test]
    public void $Method$_$State$_$Expected$()
    {
        $END$
    }
    

    and asign a shortcut like tst.

    Now, everytime you want to add a new method, you just need to start writing tst and press TAB two times, and it will create that method for you, placing the caret on the Method name. After you press Enter, the caret will move to the place you write the State name, then for the Expected, and then it will be placed where says $END$.

    Edit:
    That could be helpful too if you name all your tests with _Should. Something like:

    ConvertToInt32_NullValue_ShouldReturnTrue

    Then you can modify your template to:

    [Test]
    public void $Method$_$State$_Should$Expected$()
    {
        $END$
    }
    

    You could even try to group your naming conventions into a few groups, and create a snippet/template for each of them.

    Edit 2:
    More about this test naming convention: Naming Standards For Unit Tests, by Roy Osherove, author of The Art Of Unit Testing.

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

Sidebar

Related Questions

I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
how to create the static enum like below static enum Test{ employee-id, employeeCode }
I'm trying to create a key like this _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Shared Tools\\MSCONFIG\\startupreg\\test\\') and the key
I would like create my own collection that has all the attributes of python
I would like to create a UIView has multiple UITextFields validates each one as
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY
My create view code like this create VIEW [dbo].[vw_test] AS SELECT 'B' AS rtype,
I have created a test table in MySQL and would like to insert 10
Given an object like: class M(models.Model): test = models.BooleanField() created_date = models.DateTimeField(auto_now_add=True) Given sample
I created an error500.php file in web/errors/ and would now like to test it.

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.