GithubHelp home page GithubHelp logo

victoralm / complete-guide-to-unit-testing-in-.net-core-nunit-xunit- Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 5.78 MB

Complete Guide to Unit Testing in .NET Core (NUnit & XUnit) - Course Material

License: Apache License 2.0

C# 95.67% HTML 3.53% CSS 0.69% JavaScript 0.12%

complete-guide-to-unit-testing-in-.net-core-nunit-xunit-'s Introduction

What is Automated Testing

Write code to test the code of your application, and then repeatedly run the tests in automated fashion.

There will be two separated codes:

  • The application code: for production / development
  • The testing code: to test the application code

Manual testing

  • Not as efficient as Unit Testing
  • In order to test a class logic, you might have to:
    • Launch the application
    • Login / Register
    • Navigate to the desired page
    • Populate details
    • Verify results

Automated testing

  • Write once, run often
  • Execute anytime
  • Catch bugs before deploying
  • Very reliable and efficient
  • Confidant deployment

Types of tests

  • Unit test:
    • May test a single class or perhaps a functionally related to a class
    • Offers the best depth of testing, but doesn't cover the entire system
    • Quickly to write and execution speed
  • Integration test:
    • Potentially less in-depth than unit test, but covers a greater range of the system
    • Test the application with its external dependencies
    • Longer execution times, because of the external dependencies
  • User Interface test:
    • Covers a great range of an application, from the user interface (like a buttom click) to all the way down through tha subsystem, even right down to the database level
    • Covers a wide range, but don't go in depth. Not all of classes, nor their functionalities or properties
    • The slowest of all tests
    • Very brittle, the smallest change can break the test, since it tests a wide range of functionalities

Testing Pyramid

         = UI =
   === Integration ===
========== Unit =========

A final application should have all of the three tests, which is: Unit tests, Integration tests and UI tests. But not exactly in equal proportion... As shown in the pyramid, the biggest space is occupied by the Unit test. Then the Integration tests, to give more confidence as compared to the Unit tests. Finally, the smallest amount tha comprehends the UI tests.

Keep in mind that: more tests means more time consuming and more cost...

Logical Phases of an Automated Test

The triple A (AAA):

  • Arrange
    • Initial setup
    • Create object instances
    • Create test data
  • Act
    • Execution of application code
    • Call methods
    • Set propreties
  • Assert
    • Check results
    • Test pass / fail

complete-guide-to-unit-testing-in-.net-core-nunit-xunit-'s People

Contributors

victoralm avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.