Zurück zur Skill-Übersicht

Skill-Wissen und Projektmarkt

NUnit

Freelancer, Projekte, Experten und Wissen rund um NUnit.

Kategorie

Monitoring

Quelle

NUnit

Einordnung

NUnit Freelancer, Projekte, Experten und Wissen auf jobtic.com

NUnit gehört zu den gefragtesten Kompetenzen im modernen IT-Projektmarkt. Unternehmen, Recruiter, Projektanbieter und Agenturen suchen kontinuierlich nach qualifizierten IT-Freelancern, Beratern, Entwicklern, Consultants, Administrators, Engineers und Spezialisten mit Erfahrung in NUnit.

Auf jobtic.com finden Unternehmen und Freelancer eine moderne Plattform für IT-Projekte, Projektvermittlung, Freelancer-Profile, Experten-Suche, Projektakquise und berufliche Vernetzung rund um NUnit und viele weitere Technologien, Tools, Systeme, Methoden und IT-Bereiche.

Wikipedia

NUnit

Artikel öffnen
This article is about the C# unit testing framework. For the NGINX web application server, see NGINX Unit.
(Learn how and when to remove this message)

NUnit is an open-source unit testing framework for .NET, .NET Framework, and Mono. It serves the same purpose as JUnit does in the Java world, and is one of many in the xUnit family.[citation needed]

Features

  • Tests can be run from a console runner, within Visual Studio through a Test Adapter,[1] or through 3rd party runners.
  • Tests can be run in parallel.[2]
  • Strong support for data driven tests.[3]
  • Supports multiple platforms including .NET Core,[4] Xamarin Mobile,[5] Compact Framework[6] and Silverlight.[7]
  • Every test case can be added to one or more categories, to allow for selective running.[8]

NUnit provides a console runner (nunit3-console.exe), which is used for batch execution of tests. The console runner works through the NUnit Test Engine, which provides it with the ability to load, explore and execute tests. When tests are to be run in a separate process, the engine makes use of the nunit-agent program to run them.[citation needed]

The NUnitLite runner may be used in situations where a simpler runner is more suitable. It allows developers to create self-executing tests.[citation needed]

Assertions

NUnit provides a rich set of assertions as static methods of the Assert class. If an assertion fails, the method call does not return and an error is reported. If a test contains multiple assertions, any that follow the one that failed will not be executed. For this reason, it's usually best to try for one assertion per test.[citation needed]

Nunit 3.x is supporting multiple assertions.

[Test]
public void ComplexNumberTest()
{
    ComplexNumber result = SomeCalculation();

    Assert.Multiple(() =>
    {
        Assert.AreEqual(5.2, result.RealPart, "Real part");
        Assert.AreEqual(3.9, result.ImaginaryPart, "Imaginary part");
    });
}

Classical

Before NUnit 2.4, a separate method of the Assert class was used for each different assertion. It continues to be supported in NUnit, since many people prefer it.[citation needed]

Each assert method may be called without a message, with a simple text message or with a message and arguments. In the last case the message is formatted using the provided text and arguments.[citation needed]

// Equality asserts
Assert.AreEqual(object expected, object actual);
Assert.AreEqual(object expected, object actual, string message, params object[] parms);

Assert.AreNotEqual(object expected, object actual);
Assert.AreNotEqual(object expected, object actual, string message, params object[] parms);

// Identity asserts
Assert.AreSame(object expected, object actual);
Assert.AreSame(object expected, object actual, string message, params object[] parms);

Assert.AreNotSame(object expected, object actual);
Assert.AreNotSame(object expected, object actual, string message, params object[] parms);

// Condition asserts
// (For simplicity, methods with message signatures are omitted.)
Assert.IsTrue(bool condition);
Assert.IsFalse(bool condition);

Assert.IsNull(object anObject);
Assert.IsNotNull(object anObject);

Assert.IsNaN(double aDouble);

Assert.IsEmpty(string aString);
Assert.IsNotEmpty(string aString);

Assert.IsEmpty(ICollection collection);
Assert.IsNotEmpty(ICollection collection);

Constraint based

Beginning with NUnit 2.4, a new Constraint-based model was introduced. This approach uses a single method of the Assert class for all assertions, passing a Constraint object that specifies the test to be performed. This constraint-based model is now used internally by NUnit for all assertions. The methods of the classic approach have been re-implemented on top of this new model.[citation needed]

Example

Example of an NUnit test fixture:[citation needed]

using NUnit.Framework;
 
[TestFixture]
public class ExampleTestOfNUnit
{
    [Test]
    public void TestMultiplication()
    {
        Assert.AreEqual(4, 2*2, "Multiplication");
        
        // Equivalently, since version 2.4 NUnit offers a new and
        // more intuitive assertion syntax based on constraint objects
        // [http://www.nunit.org/index.php?p=constraintModel&r=2.4.7]:
        Assert.That(2*2, Is.EqualTo(4), "Multiplication constraint-based");
    }
}

// The following example shows different ways of writing the same exception test.

[TestFixture]
public class AssertThrowsTests
{
    [Test]
    public void Tests()
    {
        //.NET 1.x
        Assert.Throws(typeof(ArgumentException),
            new TestDelegate(MethodThatThrows));
	    
        //.NET 2.0
        Assert.Throws<ArgumentException>(MethodThatThrows);
        Assert.Throws<ArgumentException>(
	    delegate { throw new ArgumentException(); });

        // Using C# 3.0	    
        Assert.Throws<ArgumentException>( => { throw new ArgumentException(); });
    }
    
    void MethodThatThrows()
    {
        throw new ArgumentException();
    }
}

// This example shows use of the return value to perform additional verification of the exception.

[TestFixture]
public class UsingReturnValue
{
    [Test]
    public void TestException()
    {
        MyException ex = Assert.Throws<MyException>(
            delegate { throw new MyException("message", 42); });
        Assert.That(ex.Message, Is.EqualTo("message"));
        Assert.That(ex.MyParam, Is.EqualTo(42)); 
    }
}

// This example does the same thing using the overload that includes a constraint.

[TestFixture]
public class UsingConstraint
{
    [Test]
    public void TestException()
    {
        Assert.Throws(Is.Typeof<MyException>().And.Message.EqualTo("message").And.Property("MyParam").EqualTo(42),
            delegate { throw new MyException("message", 42); });
    }
}

The NUnit framework discovers the method ExampleTestOfNUnit.TestMultiplication() automatically by reflection.[citation needed]

Extensions

FireBenchmarks is an addin able to record execution time of unit tests and generate XML, CSV, XHTML performances reports with charts and history tracking. Its main purpose is to enable a developer or a team that work with an agile methodology to integrate performance metrics and analysis into the unit testing environment, to control and monitor the evolution of a software system in terms of algorithmic complexity and system resources load.[citation needed]

NUnit.Forms is an expansion to the core NUnit framework and is also open source. It specifically looks at expanding NUnit to be able to handle testing user interface elements in Windows Forms. As of January 2013, Nunit.Forms is in Alpha release, and no versions have been released since May 2006.[citation needed]

NUnit.ASP is a discontinued[9] expansion to the core NUnit framework and is also open source. It specifically looks at expanding NUnit to be able to handle testing user interface elements in ASP.NET.[citation needed]

See also

References

Bibliography

  • Hunt, Andrew; Thomas, David (2007). Pragmatic Unit Testing in C# with NUnit, 2nd Ed. The Pragmatic Bookshelf (Raleigh), 2007. ISBN 0-9776166-7-3.
  • Newkirk, Jim; Vorontsov, Alexei (2004). Test-Driven Development in Microsoft.NET. Microsoft Press (Redmond), 2004. ISBN 0-7356-1948-4.
  • Hamilton, Bill (2004). NUnit Pocket Reference. O'Reilly (Cambridge), 2004. ISBN 0-596-00739-6.

External links

Wikipedia

Dieser Text basiert auf dem Artikel NUnit aus der freien Enzyklopädie Wikipedia und steht unter der Lizenz Creative Commons CC-BY-SA 3.0 Unported. Eine Liste der Autoren ist in der Wikipedia verfügbar.

NUnit auf jobtic.com

Monitoring

Experten finden

jobtic.com verbindet IT-Freiberufler, Selbstständige, Consultants, Projektanbieter, IT-Dienstleister und Unternehmen in einer zentralen IT-Projektbörse für den deutschsprachigen Markt. Die Plattform unterstützt die Suche nach NUnit Freelancern, NUnit Projekten, Contracting-Einsätzen, Remote-Projekten, IT-Jobs, Interim-Rollen, technischen Experten und spezialisierten Beratern.

Chancen entdecken

Freelancer profitieren von einer professionellen Präsentation ihrer Expertise im Bereich NUnit und erhalten Zugriff auf aktuelle Projektangebote, Projektanfragen und neue Karrierechancen im IT-Freelancer-Markt. Durch moderne Such- und Filterfunktionen lassen sich passende Projekte, Auftraggeber, Recruiter und Kontakte schnell identifizieren.

Wissen einordnen

Neben der Projekt- und Expertenplattform bietet jobtic.com umfangreiche Informationen, Hintergründe und Wiki-Inhalte rund um NUnit. Dazu gehören Grundlagen, Definitionen, Einsatzbereiche, Entwicklungen, Versionen, Methoden, technische Zusammenhänge, Best Practices und aktuelle Marktinformationen zu NUnit.

Vernetzung stärken

Unsere jobtic-Übersicht zu NUnit kombiniert Wissensdatenbank, Projektbörse, Freelancer-Verzeichnis, Experten-Suche und Projektmarkt in einer zentralen Plattform. Besucher finden hier sowohl Informationen zu NUnit als auch passende Freelancer, Berater, Entwickler, Consultants, Administratoren, Support-Spezialisten und aktuelle IT-Projekte mit Bezug zu NUnit.

Kontakte aufbauen

jobtic.com unterstützt Freelancer und Unternehmen dabei, schneller passende Projekte, Experten und Geschäftskontakte im Bereich NUnit zu finden. Egal ob Projektakquise, Expertenvermittlung, Freelancer-Suche, Contracting, IT-Consulting oder spezialisierte Projektbesetzung - jobtic.com bietet die passende Plattform für den modernen IT-Projektmarkt.

Zentral vernetzen

Wer nach NUnit Freelancern, NUnit Experten, NUnit Projekten, NUnit Beratern, NUnit Consulting, NUnit Contracting, NUnit Projektbörse, NUnit Freelancer-Profilen oder aktuellen Entwicklungen rund um NUnit sucht, findet auf jobtic.com eine zentrale Anlaufstelle für Wissen, Projekte und professionelle Vernetzung im IT-Umfeld.

Passende Projekte zu NUnit

Mehr Projekte

Projekte veröffentlichen

Unternehmen können Projekte mit Anforderungen, Laufzeiten, Technologien, Einsatzorten, Remote-Anteilen, Budgetrahmen und Projektbeschreibungen veröffentlichen. Gleichzeitig ermöglicht jobtic.com die gezielte Suche nach verfügbaren NUnit Spezialisten mit passenden Erfahrungen, Branchenkenntnissen und technischen Fähigkeiten.

Aktuell sind keine sichtbaren Projekte verfügbar.