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

VS2017 Release- Day 2

Day 2 of the party continues and I amvs2017.png surprised by some of the comments regarding of all things, the ICON you click on to start VS2017.  I found FROM WHICH PART OF THE HELL DOES THIS ICON COME FROM?” and “I have to Hide the ICON” now the icon really has nothing to do with the functionality of VS2017, but it shows how dedicated users of this tool are.  All the icon does is open a window to possibilities of what can be created on the desktop, web/cloud and mobile for Android and IO’s.

If you install the total environment it will take up about 50 GB.  One thing about the install is you do not have to install everything.  If you’re not doing “F#” don’t install it, if you’re not a game developer don’t install Unity or Unreal.  You can save a lot of space if you never and I do mean never plan to develop for mobile.

Here are some freebies I have found so far, I like sharing the free stuff I locate while developing.  The first is 60 days of free training from Xamarin, if your part of the group that installed this week.

Another freebie I found was from Syncfusion, but only for those running the Community Edition which is great $15,960  for free.  As I find more I will post them here to let you know all about the items you may want to take a look at.

 Microsoft likes to mention a lot of things as free, but they don’t make it clear if its for VS2017 Community or Enterprise.  I hope to dig through these in the coming days and see what I can find.  If you have not downloaded VS2017 yet you should get on that now.

Happy Birthday Visual Studio!!

Today 3/7/17 Microsoft released Visual Studio 2017.  There was a lot of hoopla and examples of what you can do with the Enterprise Edition on Channel 9, which put a magnify glass on what the Pro Edition and Community Edition could not.  One of the items was the “Live Testing” that would occur while your coding.  It’s more of an enhancement from VS2015, but it’s only available in the Enterprise Edition.  Is this saying that the Community and Pro people don’t unit test their code?  You could also look at it as though those people don’t really need to increase their productivity.  It seems as though you can do a lot of stuff with AZUR if you’re a Pro or Community user, but automated unit testing is out of the question.  It also appears as though the Unit Testing is not available for .Net Core.  I will be watching this closely and try to get some traction that this would be available in all editions.

     Editor config is a new feature that sort of, kind of, does some of the functions you get from ReSharper the only drawback that I found is that you kind of have to build your own .editorconfig file.  The Documentation is about a 10 minute read and explains how to build your file.  It would have been nice if Microsoft supplied you with a file already built, I am trying not to speculate, but I think that Microsoft was not directly trying to compete with JetBrains on that front, I could be wrong though.  I have seen that many are posting the suggestion to use the file from Madskristensen / EditorConfigLanguage which was presented in a file for Roslyn.

     The last thing I want to mention is my disappointment with the fact that the Community version has an issue installing.  This was listed as a defect with VS2017RC and the solution was to install Enterprise.  Even though it was said that it was not an appropriate fix for the community version, it seems it was released that way.  All they would have had to do is apply the fix in Enterprise to the Community version.  I never tested the Pro Edition for install issues as that was not where my focus was.

#VS2017

Json2Csharp

As mentioned in my last blog I had been pointed at this utility called Json2csharp, by Bob Tabor.  It’s a free online tool that generates C# classes from your JSON code.  This lets you strongly type your JSON information being returned to you from another application through an API call, or however you may be doing it.  This is part of the JSON C# Class Generator out on CodePlex.  There is also a version out on GitHub, where some other improvements are being made.
This utility was developed by Jonathan Keith  and James Newton-King’s Json.NET.

The example I tried was using an API call from open weather map, THE API returns:  {“coord”:{“lon”:-0.13,”lat”:51.51},”weather”:[{“id”:300,”main”:”Drizzle”,”description”:”light intensity drizzle”,”icon”:”09d”}],”base”:”stations”,”main”:{“temp”:280.32,”pressure”:1012,”humidity”:81,”temp_min”:279.15,”temp_max”:281.15},”visibility”:10000,”wind”:{“speed”:4.1,”deg”:80},”clouds”:{“all”:90},”dt”:1485789600,”sys”:{“type”:1,”id”:5091,”message”:0.0103,”country”:”GB”,”sunrise”:1485762037,”sunset”:1485794875},”id”:2643743,”name”:”London”,”cod”:200}

When you paste the above JSON into the converter it returns the following classes to cut and paste into your own application

public class Coord
{
public double lon { get; set; }
public double lat { get; set; }
}
public class Weather
{
public int id { get; set; }
public string main { get; set; }
public string description { get; set; }
public string icon { get; set; }
}
public class Main
{
public double temp { get; set; }
public int pressure { get; set; }
public int humidity { get; set; }
public double temp_min { get; set; }
public double temp_max { get; set; }
}
public class Wind
{
public double speed { get; set; }
public int deg { get; set; }
}
public class Clouds
{
public int all { get; set; }
}
public class Sys
{
public int type { get; set; }
public int id { get; set; }
public double message { get; set; }
public string country { get; set; }
public int sunrise { get; set; }
public int sunset { get; set; }
}
public class RootObject
{
public Coord coord { get; set; }
public List weather { get; set; }
public string @base { get; set; }
public Main main { get; set; }
public int visibility { get; set; }
public Wind wind { get; set; }
public Clouds clouds { get; set; }
public int dt { get; set; }
public Sys sys { get; set; }
public int id { get; set; }
public string name { get; set; }
public int cod { get; set; }
}

I feel this is a great utility if you didn’t know about it, you now do.

Learning Universal Windows Platform

What do you do when you’re an out of work developer?  Well you can’t just sit around and watch TV.  You need to do something after you have finished your resume and send it out to 50+ places you think you may want to work.  For me I am working on this Blog and learning about Universal Windows Platform, UWP for short.  The first place I started looking for information was at Microsoft Virtual Academy.  They have a lot of educational videos for Beginners to Cloud Development.  I found a course from Bob Tabor that takes you step by step in developing UWP applications. I have some screen shots of the ones I built while following a long, as bob goes in depth of how they work. This first one here was a Sound Dash Board that would play sounds and you can Drag & Drop a WAV or MP3 file onto the screen and it would play them.

sound

To figure out how to make the drag and drop work Bob walks you through an example solution with the sole purpose of only doing Drag and Drop.

drop

This is the Example application we created to learn to Drag and Drop items onto the window.

codedrag

Bobs course has many helpful hints like this website json2csharp, when you make an API call and receive Json back you can paste the Json into the converter and it will code all your classes to paste into your application.

weather

For the weather application we called an API to get the weather data. This application should work on your Desktop and a windows phone.

I have been collecting many useful URLs as I go that will contribute to your development efforts, I have listed a few below:

  • Guidelines for tiles and badges – This explains what “tiles” are and what “live tiles” are, in regard to the user experience for using your application. They are general guidelines to help you match the look and feel to other applications.
  • Get the user’s location – This site explains how to get the user location from a desktop or a windows phone, which is very helpful.
  • Tile Template Catalog – This site is a catalog of most of the windows 10 template that you would use and specifies the content template to use in a tile update.