Testing! Testing! Testing!

Everyone talks about testing, but who does it?  In a move-left environment this is put on the developer and in a move-right environment this may be performed by a testing team.  In either case testing is the process of breaking the application, if you can.  Breaking the application is defined as not fulfilling the requirements documentation, is there a situation that may fail?  I am going to lay out a development process that I believe will work for new development, but you will need to do some customizing for applications that already exist.  The reason for the customization is that there is a possibility you may find bugs that the estimator may not have intended to correct.  The best thing to do is to start testing only the changes you are making and verify that you are not inserting bad code.  You can leave testing of the rest of the application for future projects.  As part of your testing process you will need to have a way to log the defects that are found and when they are corrected.  Microsoft does have a Testing Center, but Testing Center provides access to the test hub in Visual Studio Team Foundation Server and Visual Studio Team Services and is not part of VS2017 Community.  You may also need to have in place a Change Log Process should the testing produce an outcome that was assumed and never documented in the Functional Documentation or the Technical Documentation.

Visual Studio supports many different testing frameworks MSTest, NUnit and Moq are just a handful.  In the link I provided for MSTest the example there is using the VS2017 Enterprise, which has more bells and whistles.

Now the process I would follow for development of a new application is take the “Technical Document” and paste it into a single application file and in the case of C# it could be something to the effect of MyProgram.cs.  You would then select all that you pasted in and make it comments, which is easy to do.  I suggest to use the //this is a comment, instead of the /* this is a comment */, because you are going to break this up into your methods.  As you are creating the methods just have the comments that states what it will perform.  If you have a method that will do this and that you should look at breaking that down to one item.  An example would look like this:

static void FutureFeature()
{
    // Explain what the FutureFeature is to do.
    throw new NotImplementedException();
}

Now the next step is to create your test cases for your methods, at this point you have to decide which framework you want to use. MSTest, NUnit, Moq or whatever is your organizations standard is.  You write your test code based on the test cases provided to you from the person who developed them, if it’s not yourself.

VS Community doesn’t support automated tests and the tests are considered to be “White Box” testing.  White Box testing is when you have the knowledge of the code and you are testing the method based on that knowledge.  When building the test cases they are for unit testing only and you don’t want to be testing calls to databases as that would be considered End-to-End testing.  In the testing project you will have something like this:

[TestClass]    
public class UnitTest1    
{
        [TestMethod]
        public void FutureFeaturetest()
        {
        }

To add MSTest to your application you need the following items:

Using the NuGet Packet Manager locate MSTest and install

  • MSTest .TestAdapter
  • MSTest .TestFramework.

To add NUnit to your application you need the following items:

Using the NuGet Packet Manager locate NUnit and install

  • NUnit by Charlie Poole
  • NUnit. Runners by Charlie Pool
  • NUnit. ConsoleRunners by Charlie Pool
  • NUnit. Console by Charlie Pool
  • NUnit3TestAdapter by Charlie Pool
  • NUnit. Extention.NUnitProjectLoader by Charlie Pool
  • NUnit.Extention.NUnitV2ResultWriter by Charlie Pool
  • NUnit.Extention.NUnitV2Driver by Charlie Pool

To add Moq to your application you need the following items:

Using the NuGet Packet Manager locate Moq and install

  • Moq by Daniel Cazzulino

There is information you can get from Microsoft Virtual Academy

I don’t want this to get to long so I will continue this for a little longer.  If you have questions please leave a comment or if you like what you are seeing like and share with your friends.  Please subscribe to my blog.

Thanks

Advertisements