SlideShare ist ein Scribd-Unternehmen logo
1 von 23
MAXIME LEMAITRE – 10/09/2015
xUnit.net
… Assert.Awesome(‘‘xUnit.net’’)…
Agenda
• Business Card
• Why xUnit.net ?
• Compatibility & Comparisons
• Concepts
• Extensibility
• Demo
• Conclusion
• Question
xUnit.net Business Card
• Created in 2007 by 2 ex-Microsofteees
– James Newkirk @jamesnewkirk
– Brad Wilson @bradwilson
• Quick links
– http://xunit.github.io
Official web site
– https://github.com/xunit
850 commits, 800 stars, 35 contributors, 250 forks
– https://twitter.com/xunit
1400 followers
– https://www.nuget.org/packages/xunit
More than 1M downloads (just for the main pkg)
(2007) – “Since the release of NUnit 2.0,
there have been millions of lines of code
written using the various unit testing
frameworks for .NET. About a year ago it
became clear to myself –James- and Brad
that there were some very clear patterns
of success (and failure) with the tools we
were using for writing tests. Rather than
repeating guidance about “do X” or “don’t
do Y”, it seemed like it was the right time to
reconsider the framework itself and see if
we could codify some of those rules.”,
James Newkirk
Lessons learned in Unit Testing (2007)
1. Write tests using the 3A pattern (Arrange, Act, Assert)
2. Keep Your Tests Close (to production code)
3. Use Alternatives to ExpectedException (leads to
uncertainty, violates AAA)
4. Use Small Fixtures (smaller & more focused test classes)
5. Don’t use SetUp/TearDown, TestInit/TestCleanup, …
(improve readability & isolation)
6. Don’t use abstract base test classes (improve readability
& isolation)
7. Improve testability with Inversion of Control (Better test
isolation & decoupled class implementation
Why Build xUnit.net ?
http://bradwilson.typepad.com/presentations/xunit-v2.pdf
• Flexibility: static and private methods
• Reduce Friction: fewer attributes
• Safety: create a new instance for every test
• Be explicit: no control flow in attributes
• Runners: be everywhere the developer is
• Consistency: Prefer the language & framework
• Extensibility: not an afterthought
• TDD first: built with and for TDD
Test Runner Compatibility
Comparing xUnit.net to other frameworks
Unit 2.2 MSTest 2005 xUnit.net 2.x Comments
[Test] [TestMethod] [Fact] Marks a test method.
[TestFixture] [TestClass] n/a
xUnit.net does not require an attribute for a test class; it
looks for all test methods in all public lasses in the assembly.
[ExpectedException]
[ExpectedExce
ption]
Assert.Throws
Record.Exception
xUnit.net has done away with the ExpectedException
[SetUp] [TestInitialize] Constructor
We believe that use of [SetUp] is generally bad. However,
you can implement a parameterless constructor as a direct
replacement.
[TearDown] [TestCleanup] IDisposable.Dispose
We believe that use of [TearDown] is generally bad, but you
can implementIDisposable.Dispose as a direct replacement.
[TestFixtureSetUp] [ClassInitialize] IClassFixture<T> To get per-class fixture setup, use IClassFixture<T>
[TestFixtureTearDown] [ClassCleanup] IClassFixture<T> To get per-class fixture teardown, use IClassFixture<T>
n/a n/a ICollectionFixture<T>
To get per-collection fixture setup and teardown,
implement ICollectionFixture<T> on your test collection.
[Ignore] [Ignore] [Fact(Skip="reason")] Set the Skip parameter on the [Fact] attribute.
[Property] [TestProperty] [Trait] Set arbitrary metadata on a test
n/a [DataSource]
[Theory]
[XxxData]
Theory (data-driven test).
Comparing xUnit.net to other frameworks
NUnit 2.2 MSTest 2005 xUnit.net 1.x Comments
AreEqual
AreNotEqual
AreEqual
AreNotEqual
Equal
NotEqual
MSTest and xUnit.net support generic versions of
this method
AreNotSame
AreSame
AreNotSame
AreSame
NotSame
Same
n/a n/a DoesNotThrow
Ensures that the code does not throw any
exceptions
Greater / Less n/a n/a
xUnit.net alternative: Assert.True(x > y)
Assert.True(x < y)
Ignore Inconclusive n/a
IsEmpty
IsNotEmpty
n/a
Empty
NotEmpty
IsFalse
IsTrue
IsFalse
IsTrue
False
True
IsInstanceOfType
IsNotInstanceOfType
IsInstanceOfType
IsNotInstanceOfType
IsType
IsNotType
IsNotNull
IsNull
IsNotNull
IsNull
NotNull
Null
n/a n/a NotInRange Ensures that a value is not in a given inclusive range
n/a n/a Throws Ensures that the code throws an exact exception
Concepts
Two different major types of unit tests
Facts are tests which are always true.
They test invariant conditions.
Theories are tests which are only true for a
particular set of data (Data Driven Tests)
More data sources for theories
PropertyData ClassData
11
Shared Context between Tests
http://xunit.github.io/docs/shared-context.html
Constructor and Dispose
shared setup/cleanup code
without sharing object instances
Class Fixtures
shared object instance across
tests in a single class
Collection Fixtures
shared object instances across
multiple test classes
Extensibility
xUnit Extensibility
Half a decade of developer requests
• Assert (Sample: AssertExtensions )
Use 3rd party assertions or create custom
• Before/After (Sample : UseCulture)
Run code before & after each test runs
• Class Fixtures (Sample : ClassFixtureExample)
Run code before & after all tests in test class
• Collection Fixtures (Sample: CollectionFixtureExample )
Run code before & after all tests in test collection
• Theory Data (Sample: ExcelDataExample )
Provide new DataAttribute
• Test Ordering (Sample: TestOrderExamples)
• Traits (Sample: TraitExtensibility)
• FactAttribute (Sample: TheoryAttribute)
What does it mean to be a test?
• Test frameworks
What does it mean to find and run tests?
• Runners
And the Test result is GREEN.
The AutoDataAttribute simply uses a Fixture
object to create the objects declared in the
unit tests parameter list (primitives and
complex types like Mock<T>)…
15
Mixing all together …
xUnit+Moq+AutoFixture
What is the result
of this test ?
Demo
Getting Started
http://xunit.github.io/docs/getting-started.html
1. Create a class library
A test project is just a class library
2. Add a reference to xUnit.net
3. Write your first tests
4. Add a reference to a xUnit.net runner
Console or VS
Running Tests
Via Visual Studio Test Explorer
Install-Package
xunit.runner.visualstudio
Via the console test runner
Install-Package xunit.runner.console
Via any test runner …
• Nuget ‘All the way’
No vsix to install, no templates to install, no setups, … simply nuget as we love it
• Great Community & Active Development
xUnit.net is free and open source. The code is hosted on github (850 commits, 3R
contibutors, 800 stars, 250 forks) and the official twitter account has 1400
followers. Many extensions are available (Moq, AutoFixture, …)
• Part of the Next ‘Big Thing’
Do you know ASP.NET 5, Xamarin, DNX, …? xUnit will be the first class citizen and
default choice in .NET in the future
• Well Integrated in the .NET Ecosystem
No troubles to use it because it is already supported everywhere : Team
Foundation Server, CruiseControl.net, AppVeyor, TeamCity, Resharper …
• It Helps to Write “Better, Faster, Stronger” Tests
This is the essence of xUnit.net. codify patterns of success (and failure)
19
Why moving to xUnit ?
Questions
References
• http://xunit.github.io/
• http://jamesnewkirk.typepad.com/LessonsLearnedinProgrammerTesting.pdf
• http://bradwilson.typepad.com/presentations/xunit-v2.pdf
• http://www.codeproject.com/Articles/825248/The-Dynamic-Duo-of-Unit-Testing-xUnit-net-and-Auto
• https://github.com/xunit/samples.xunit
• http://blog.ploeh.dk/2010/10/08/AutoDataTheorieswithAutoFixture/
About Us
• Betclic Everest Group, one of the world leaders in online
gaming, has a unique portfolio comprising various
complementary international brands: Betclic, Everest
Poker/Casino, Bet-at-home, Expekt, Imperial Casino, Monte-
Carlo Casino…
• Through our brands, Betclic Everest Group places expertise,
technological know-how and security at the heart of our
strategy to deliver an on-line gaming offer attuned to the
passion of our players. We want our brands to be easy to use
for every gamer around the world. We’re building our
company to make that happen.
• Active in 100 countries with more than 12 million customers
worldwide, the Group is committed to promoting secure and
responsible gaming and is a member of several international
professional associations including the EGBA (European
Gaming and Betting Association) and the ESSA (European
Sports Security Association).
We want our Sports betting, Poker, Horse racing and
Casino & Games brands to be easy to use for every
gamer around the world. Code with us to make that
happen.
Look at all the challenges we offer HERE
Check our Employer Page
Follow us on LinkedIn
WE’RE HIRING !

Weitere ähnliche Inhalte

Was ist angesagt?

Singleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation PatternSingleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation PatternSeerat Malik
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive ExtensionsRTigger
 
Unit testing framework
Unit testing frameworkUnit testing framework
Unit testing frameworkIgor Vavrish
 
Observer & singleton pattern
Observer  & singleton patternObserver  & singleton pattern
Observer & singleton patternbabak danyal
 
Property based testing - Less is more
Property based testing - Less is moreProperty based testing - Less is more
Property based testing - Less is moreHo Tien VU
 
Application of the Actor Model to Large Scale NDE Data Analysis
Application of the Actor Model to Large Scale NDE Data AnalysisApplication of the Actor Model to Large Scale NDE Data Analysis
Application of the Actor Model to Large Scale NDE Data AnalysisChrisCoughlin9
 
Java - Singleton Pattern
Java - Singleton PatternJava - Singleton Pattern
Java - Singleton PatternCharles Casadei
 
Csise15 codehunt
Csise15 codehuntCsise15 codehunt
Csise15 codehuntTao Xie
 
Transferring Software Testing and Analytics Tools to Practice
Transferring Software Testing and Analytics Tools to PracticeTransferring Software Testing and Analytics Tools to Practice
Transferring Software Testing and Analytics Tools to PracticeTao Xie
 
Learning on Deep Learning
Learning on Deep LearningLearning on Deep Learning
Learning on Deep LearningShelley Lambert
 
Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019Vincent Massol
 
Iterator Design Pattern
Iterator Design PatternIterator Design Pattern
Iterator Design PatternVarun Arora
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projectsVincent Massol
 

Was ist angesagt? (20)

Singleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation PatternSingleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation Pattern
 
Reactive Extensions
Reactive ExtensionsReactive Extensions
Reactive Extensions
 
Singleton Pattern
Singleton PatternSingleton Pattern
Singleton Pattern
 
Unit testing framework
Unit testing frameworkUnit testing framework
Unit testing framework
 
Observer & singleton pattern
Observer  & singleton patternObserver  & singleton pattern
Observer & singleton pattern
 
Property based testing - Less is more
Property based testing - Less is moreProperty based testing - Less is more
Property based testing - Less is more
 
Application of the Actor Model to Large Scale NDE Data Analysis
Application of the Actor Model to Large Scale NDE Data AnalysisApplication of the Actor Model to Large Scale NDE Data Analysis
Application of the Actor Model to Large Scale NDE Data Analysis
 
Javasession6
Javasession6Javasession6
Javasession6
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
 
Java - Singleton Pattern
Java - Singleton PatternJava - Singleton Pattern
Java - Singleton Pattern
 
Csise15 codehunt
Csise15 codehuntCsise15 codehunt
Csise15 codehunt
 
Transferring Software Testing and Analytics Tools to Practice
Transferring Software Testing and Analytics Tools to PracticeTransferring Software Testing and Analytics Tools to Practice
Transferring Software Testing and Analytics Tools to Practice
 
Easy mock
Easy mockEasy mock
Easy mock
 
Learning on Deep Learning
Learning on Deep LearningLearning on Deep Learning
Learning on Deep Learning
 
Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019Advanced Java Testing @ POSS 2019
Advanced Java Testing @ POSS 2019
 
Iterator Design Pattern
Iterator Design PatternIterator Design Pattern
Iterator Design Pattern
 
Building XWiki
Building XWikiBuilding XWiki
Building XWiki
 
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
 
Writing testable code
Writing testable codeWriting testable code
Writing testable code
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projects
 

Ähnlich wie Mini training - Moving to xUnit.net

Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxKnoldus Inc.
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projectsVincent Massol
 
Test Driven Development with Sql Server
Test Driven Development with Sql ServerTest Driven Development with Sql Server
Test Driven Development with Sql ServerDavid P. Moore
 
Net campus2015 antimomusone
Net campus2015 antimomusoneNet campus2015 antimomusone
Net campus2015 antimomusoneDotNetCampus
 
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATAPREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATADotNetCampus
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxVictor Rentea
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBaskar K
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)Rob Hale
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchMats Bryntse
 
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Codecamp Romania
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google MockICS
 
xUnit Style Database Testing
xUnit Style Database TestingxUnit Style Database Testing
xUnit Style Database TestingChris Oldwood
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django ApplicationsGareth Rushgrove
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseUTC Fire & Security
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10Erik Sowa
 

Ähnlich wie Mini training - Moving to xUnit.net (20)

Unit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptxUnit Testing in .NET Core 7.0 with XUnit.pptx
Unit Testing in .NET Core 7.0 with XUnit.pptx
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
New types of tests for Java projects
New types of tests for Java projectsNew types of tests for Java projects
New types of tests for Java projects
 
Test Driven Development with Sql Server
Test Driven Development with Sql ServerTest Driven Development with Sql Server
Test Driven Development with Sql Server
 
Net campus2015 antimomusone
Net campus2015 antimomusoneNet campus2015 antimomusone
Net campus2015 antimomusone
 
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATAPREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
PREDICT THE FUTURE , MACHINE LEARNING & BIG DATA
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptx
 
Beginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NETBeginners - Get Started With Unit Testing in .NET
Beginners - Get Started With Unit Testing in .NET
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
Iasi code camp 20 april 2013 marian chicu - database unit tests in the sql se...
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
 
xUnit Style Database Testing
xUnit Style Database TestingxUnit Style Database Testing
xUnit Style Database Testing
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 

Mehr von Betclic Everest Group Tech Team

Mini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedMini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedBetclic Everest Group Tech Team
 

Mehr von Betclic Everest Group Tech Team (20)

Mini training - Reactive Extensions (Rx)
Mini training - Reactive Extensions (Rx)Mini training - Reactive Extensions (Rx)
Mini training - Reactive Extensions (Rx)
 
Mini training - Introduction to Microsoft Azure Storage
Mini training - Introduction to Microsoft Azure StorageMini training - Introduction to Microsoft Azure Storage
Mini training - Introduction to Microsoft Azure Storage
 
Akka.Net
Akka.NetAkka.Net
Akka.Net
 
Mini training- Scenario Driven Design
Mini training- Scenario Driven DesignMini training- Scenario Driven Design
Mini training- Scenario Driven Design
 
Email Management in Outlook
Email Management in OutlookEmail Management in Outlook
Email Management in Outlook
 
Mini-Training: SSO with Windows Identity Foundation
Mini-Training: SSO with Windows Identity FoundationMini-Training: SSO with Windows Identity Foundation
Mini-Training: SSO with Windows Identity Foundation
 
Training - What is Performance ?
Training  - What is Performance ?Training  - What is Performance ?
Training - What is Performance ?
 
Mini-Training: Docker
Mini-Training: DockerMini-Training: Docker
Mini-Training: Docker
 
Mini Training Flyway
Mini Training FlywayMini Training Flyway
Mini Training Flyway
 
Mini-Training: NDepend
Mini-Training: NDependMini-Training: NDepend
Mini-Training: NDepend
 
Management 3.0 Workout
Management 3.0 WorkoutManagement 3.0 Workout
Management 3.0 Workout
 
Lean for Business
Lean for BusinessLean for Business
Lean for Business
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
Mini-Training: Mobile UX Trends
Mini-Training: Mobile UX TrendsMini-Training: Mobile UX Trends
Mini-Training: Mobile UX Trends
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Mini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedMini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation Demystified
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Mini-Training: Roslyn
Mini-Training: RoslynMini-Training: Roslyn
Mini-Training: Roslyn
 

Kürzlich hochgeladen

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 

Kürzlich hochgeladen (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Mini training - Moving to xUnit.net

  • 1. MAXIME LEMAITRE – 10/09/2015 xUnit.net … Assert.Awesome(‘‘xUnit.net’’)…
  • 2. Agenda • Business Card • Why xUnit.net ? • Compatibility & Comparisons • Concepts • Extensibility • Demo • Conclusion • Question
  • 3. xUnit.net Business Card • Created in 2007 by 2 ex-Microsofteees – James Newkirk @jamesnewkirk – Brad Wilson @bradwilson • Quick links – http://xunit.github.io Official web site – https://github.com/xunit 850 commits, 800 stars, 35 contributors, 250 forks – https://twitter.com/xunit 1400 followers – https://www.nuget.org/packages/xunit More than 1M downloads (just for the main pkg) (2007) – “Since the release of NUnit 2.0, there have been millions of lines of code written using the various unit testing frameworks for .NET. About a year ago it became clear to myself –James- and Brad that there were some very clear patterns of success (and failure) with the tools we were using for writing tests. Rather than repeating guidance about “do X” or “don’t do Y”, it seemed like it was the right time to reconsider the framework itself and see if we could codify some of those rules.”, James Newkirk
  • 4. Lessons learned in Unit Testing (2007) 1. Write tests using the 3A pattern (Arrange, Act, Assert) 2. Keep Your Tests Close (to production code) 3. Use Alternatives to ExpectedException (leads to uncertainty, violates AAA) 4. Use Small Fixtures (smaller & more focused test classes) 5. Don’t use SetUp/TearDown, TestInit/TestCleanup, … (improve readability & isolation) 6. Don’t use abstract base test classes (improve readability & isolation) 7. Improve testability with Inversion of Control (Better test isolation & decoupled class implementation
  • 5. Why Build xUnit.net ? http://bradwilson.typepad.com/presentations/xunit-v2.pdf • Flexibility: static and private methods • Reduce Friction: fewer attributes • Safety: create a new instance for every test • Be explicit: no control flow in attributes • Runners: be everywhere the developer is • Consistency: Prefer the language & framework • Extensibility: not an afterthought • TDD first: built with and for TDD
  • 7. Comparing xUnit.net to other frameworks Unit 2.2 MSTest 2005 xUnit.net 2.x Comments [Test] [TestMethod] [Fact] Marks a test method. [TestFixture] [TestClass] n/a xUnit.net does not require an attribute for a test class; it looks for all test methods in all public lasses in the assembly. [ExpectedException] [ExpectedExce ption] Assert.Throws Record.Exception xUnit.net has done away with the ExpectedException [SetUp] [TestInitialize] Constructor We believe that use of [SetUp] is generally bad. However, you can implement a parameterless constructor as a direct replacement. [TearDown] [TestCleanup] IDisposable.Dispose We believe that use of [TearDown] is generally bad, but you can implementIDisposable.Dispose as a direct replacement. [TestFixtureSetUp] [ClassInitialize] IClassFixture<T> To get per-class fixture setup, use IClassFixture<T> [TestFixtureTearDown] [ClassCleanup] IClassFixture<T> To get per-class fixture teardown, use IClassFixture<T> n/a n/a ICollectionFixture<T> To get per-collection fixture setup and teardown, implement ICollectionFixture<T> on your test collection. [Ignore] [Ignore] [Fact(Skip="reason")] Set the Skip parameter on the [Fact] attribute. [Property] [TestProperty] [Trait] Set arbitrary metadata on a test n/a [DataSource] [Theory] [XxxData] Theory (data-driven test).
  • 8. Comparing xUnit.net to other frameworks NUnit 2.2 MSTest 2005 xUnit.net 1.x Comments AreEqual AreNotEqual AreEqual AreNotEqual Equal NotEqual MSTest and xUnit.net support generic versions of this method AreNotSame AreSame AreNotSame AreSame NotSame Same n/a n/a DoesNotThrow Ensures that the code does not throw any exceptions Greater / Less n/a n/a xUnit.net alternative: Assert.True(x > y) Assert.True(x < y) Ignore Inconclusive n/a IsEmpty IsNotEmpty n/a Empty NotEmpty IsFalse IsTrue IsFalse IsTrue False True IsInstanceOfType IsNotInstanceOfType IsInstanceOfType IsNotInstanceOfType IsType IsNotType IsNotNull IsNull IsNotNull IsNull NotNull Null n/a n/a NotInRange Ensures that a value is not in a given inclusive range n/a n/a Throws Ensures that the code throws an exact exception
  • 10. Two different major types of unit tests Facts are tests which are always true. They test invariant conditions. Theories are tests which are only true for a particular set of data (Data Driven Tests)
  • 11. More data sources for theories PropertyData ClassData 11
  • 12. Shared Context between Tests http://xunit.github.io/docs/shared-context.html Constructor and Dispose shared setup/cleanup code without sharing object instances Class Fixtures shared object instance across tests in a single class Collection Fixtures shared object instances across multiple test classes
  • 14. xUnit Extensibility Half a decade of developer requests • Assert (Sample: AssertExtensions ) Use 3rd party assertions or create custom • Before/After (Sample : UseCulture) Run code before & after each test runs • Class Fixtures (Sample : ClassFixtureExample) Run code before & after all tests in test class • Collection Fixtures (Sample: CollectionFixtureExample ) Run code before & after all tests in test collection • Theory Data (Sample: ExcelDataExample ) Provide new DataAttribute • Test Ordering (Sample: TestOrderExamples) • Traits (Sample: TraitExtensibility) • FactAttribute (Sample: TheoryAttribute) What does it mean to be a test? • Test frameworks What does it mean to find and run tests? • Runners
  • 15. And the Test result is GREEN. The AutoDataAttribute simply uses a Fixture object to create the objects declared in the unit tests parameter list (primitives and complex types like Mock<T>)… 15 Mixing all together … xUnit+Moq+AutoFixture What is the result of this test ?
  • 16. Demo
  • 17. Getting Started http://xunit.github.io/docs/getting-started.html 1. Create a class library A test project is just a class library 2. Add a reference to xUnit.net 3. Write your first tests 4. Add a reference to a xUnit.net runner Console or VS
  • 18. Running Tests Via Visual Studio Test Explorer Install-Package xunit.runner.visualstudio Via the console test runner Install-Package xunit.runner.console Via any test runner …
  • 19. • Nuget ‘All the way’ No vsix to install, no templates to install, no setups, … simply nuget as we love it • Great Community & Active Development xUnit.net is free and open source. The code is hosted on github (850 commits, 3R contibutors, 800 stars, 250 forks) and the official twitter account has 1400 followers. Many extensions are available (Moq, AutoFixture, …) • Part of the Next ‘Big Thing’ Do you know ASP.NET 5, Xamarin, DNX, …? xUnit will be the first class citizen and default choice in .NET in the future • Well Integrated in the .NET Ecosystem No troubles to use it because it is already supported everywhere : Team Foundation Server, CruiseControl.net, AppVeyor, TeamCity, Resharper … • It Helps to Write “Better, Faster, Stronger” Tests This is the essence of xUnit.net. codify patterns of success (and failure) 19 Why moving to xUnit ?
  • 21. References • http://xunit.github.io/ • http://jamesnewkirk.typepad.com/LessonsLearnedinProgrammerTesting.pdf • http://bradwilson.typepad.com/presentations/xunit-v2.pdf • http://www.codeproject.com/Articles/825248/The-Dynamic-Duo-of-Unit-Testing-xUnit-net-and-Auto • https://github.com/xunit/samples.xunit • http://blog.ploeh.dk/2010/10/08/AutoDataTheorieswithAutoFixture/
  • 22. About Us • Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio comprising various complementary international brands: Betclic, Everest Poker/Casino, Bet-at-home, Expekt, Imperial Casino, Monte- Carlo Casino… • Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players. We want our brands to be easy to use for every gamer around the world. We’re building our company to make that happen. • Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association).
  • 23. We want our Sports betting, Poker, Horse racing and Casino & Games brands to be easy to use for every gamer around the world. Code with us to make that happen. Look at all the challenges we offer HERE Check our Employer Page Follow us on LinkedIn WE’RE HIRING !