Running unit tests in Visual Studio

Once you have some unit tests created, you can start running them directly from Visual Studio. Typically, this should be done as tests are created throughout your development lifecycle as well as before you commit your code to source control, especially if there is a continuous integration process that will automatically build your code and run the tests.

After the tests have completed running, the results will appear in the Test Results pane:

Notice (in the preceding screenshot) that one of our unit tests is failing. In order to get this test to pass, we will need to go back and update DetailViewModel by overriding  the empty Init method of BaseViewModel and have it throw a new
EntryNotProvidedException instance, as follows; this type of iterative testing development process is a common best practice that helps you develop better code with more testing coverage:

public class DetailViewModel : BaseViewModel<TripLogEntry>
{
// ...

public override async Task Init()
{
throw new EntryNotProvidedException();
}

public override async Task Init(TripLogEntry logEntry)
{
Entry = logEntry;
}
}

Now, when you rerun the unit tests, they should all pass:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.59