SlideShare una empresa de Scribd logo
1 de 26
INTRODUCTION
TO
MSPEC          AND OTHER STUFF


Edward Wilde
A LITTLE
ABOUT ME


              
           I’M NOT
           RELIGIOUS
           AN EXPERT
              BUT SOME CLIENTS ARE
UNIT TESTING             Arrange-Act-Assert
BASICS                   a pattern for arranging and
                         formatting code in UnitTest
                         methods:
               Arrange   http://c2.com/cgi/wiki?ArrangeActAssert


                         Arrange all necessary preconditions
               Act       and inputs.

                         Act on the object or method under

               Assert    test.

                         Assert that the expected results
                         have occurred.
CODE
BREAK
        DEMO ARRANGE ACT ASSERT
BDD
WHAT IS IT?
              TDD with some structure

              • Test names should be sentences


              • Tests should be focused


              • Tracing requirements, executable acceptance criteria
STORY        Feature:        Short  clear
BASED        As an           actor of the system
TESTING      I want          to perform some action
             In order to     realize some business value

User story   Scenario:       Some business situation
                Given some context
                And some other condition
                When the actor perform an action
Acceptance      Then the outcome is achieved
Criteria        And some other outcome is achieved

             Scenario:       Some other situation related to the
                             same story
USER STORY   Feature:          Account transfer
EXAMPLE      As a              customer
             I want            to transfer money between accounts online
             In order to       avoid having to telephone my bank to carry do this


             Scenario:       Account has required funds
                Given the source account is sufficient
                And the customer has signed up to online banking
                When the customer transfers money between accounts
                Then the target account is credited immediately
                And the source account is debited immediately

             Scenario:       Account has insufficient funds
                 Given the source account is insufficient funds...
CODE
BREAK
        Creating a BDD test using SPEC FLOW
ENTER
MSPEC
        CONTEXT SPECIFICATION FRAMEWORK

              CONTEXT == ARRANGE or GIVEN

              SPECIFICATION == ASSERT or THEN

        DEVELOPER CENTRIC

        BETTER FOR UNIT TESTING
TEST        when_describe_context {
STRUCTURE    Establish context = ()      Arrange Given

            Because of = () =...
                                          Act      When
            It should_...() =...
                                          Assert   Then
            It should_...() =...

             Cleanup test_data () =...
            }
INSTALLATION

               Using chocolatey:
                       cinst machine.specifications
                       run InstallResharperRunner.7.1

               Resharper live templates

               Resharper settings – see resources
CODE
BREAK
        Creating an mspec test
TESTING    Behaves_likeTBehavior
BEHAVIOR
           [Behaviors]
           public class AccountInCredit
           {
             protected static Account account;

           It should_have_a_positive_balance = () =
           account.Balance.ShouldBeGreaterThan(0m);
           }
CODE
BREAK

        Creating an mspec test using behaviors
MACHINE
FAKES
          Integrates machine.specifications and mocking

          Auto-mocking container

          Choose between:
                  RhinoMocks, Moq, NSubstitue and FakeItEasy

          Install-Package machine.specifications.moq
MACHINE FAKES
WITHFAKES
            WithFakes

            Base class giving you access to

            AnTFake or SomeTFake to create fakes

            WhenToldTo(x=x.foo).Return(3) // create an
            expectation
            WasToldTo(x=x.foo) // verfiy an expectation
            ParamT
CODE
BREAK
        Creating a test using WithFakes
MACHINE FAKES
WITHSUBJECT
            WithSubjectT

            Automocking container
            Creates subject under test for you

            TheTinterface access existing fakes
CODE
BREAK
        Creating a test using WithSubjectT
MACHINE.FAKES
REUSING CONTEXT
            OnEstablish context = fake =
            {
              fake
                    .TheIFoo
                    .WhenToldTo(x=x.Bar())
                    .Return(“Baz”);
            }

            OnCleanup sub
CODE
BREAK
        Creating a test reusing context setup code.
MSPEC
ALT
        SHARPDEVELOP

        TEAM CITY

        COMMAND LINE

        MSBUILD TASK
LESSONS
I LEARNED
            Treat test code like production code

            Use DI and Factories

            Be wary of inheritance

            Tests should be simple

            Don’t be scared to delete tests
RESOURCES

            Machine.Specifications
            https://github.com/machine/machine.specifications


            Machine.Fakes
            https://github.com/machine/machine.fakes


            Resharper templates
            http://therightstuff.de/2010/03/03/MachineSpecifications-Templates-For-ReSharper.aspx


            Resharper settings
            http://www.thebooleanfrog.com/post/2011/11/24/ReSharper-StyleCop-and-MSpec-All-Together-
            Now.aspx
PROJECTS USING
MSPEC
            Fluent NHibernate
            http://www.fluentnhibernate.org/


            Should Assertion Library
            http://should.codeplex.com




            EventStore
            https://github.com/joliver/EventStore


            Who-Can-Help-Me
            https://github.com/jongeorge1/Who-Can-Help-Me
DRIVE
HOME
SAFELY
blogs.edwardwilde.com

Más contenido relacionado

La actualidad más candente

Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQueryKnoldus Inc.
 
Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015CiaranMcNulty
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit TestChiew Carol
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyIgor Napierala
 
AngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and JasmineAngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and Jasminefoxp2code
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSJim Lynch
 
Testing javascript in the frontend
Testing javascript in the frontendTesting javascript in the frontend
Testing javascript in the frontendFrederic CABASSUT
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Vysakh Sreenivasan
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Codescidept
 
JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101Hazem Saleh
 
JavaScript Coding Guidelines
JavaScript Coding GuidelinesJavaScript Coding Guidelines
JavaScript Coding GuidelinesOleksii Prohonnyi
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript TestingThomas Fuchs
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineAnup Singh
 
RSpec 3: The new, the old, the good
RSpec 3: The new, the old, the goodRSpec 3: The new, the old, the good
RSpec 3: The new, the old, the goodmglrnm
 
Building Quality with Foundations of Mud
Building Quality with Foundations of MudBuilding Quality with Foundations of Mud
Building Quality with Foundations of Mudseleniumconf
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 

La actualidad más candente (20)

Jasmine BDD for Javascript
Jasmine BDD for JavascriptJasmine BDD for Javascript
Jasmine BDD for Javascript
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015Why Your Test Suite Sucks - PHPCon PL 2015
Why Your Test Suite Sucks - PHPCon PL 2015
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishy
 
Angular testing
Angular testingAngular testing
Angular testing
 
AngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and JasmineAngularJS Unit Testing w/Karma and Jasmine
AngularJS Unit Testing w/Karma and Jasmine
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
Testing javascript in the frontend
Testing javascript in the frontendTesting javascript in the frontend
Testing javascript in the frontend
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101
 
JavaScript Coding Guidelines
JavaScript Coding GuidelinesJavaScript Coding Guidelines
JavaScript Coding Guidelines
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript Testing
 
Clean tests good tests
Clean tests   good testsClean tests   good tests
Clean tests good tests
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & Jasmine
 
RSpec 3: The new, the old, the good
RSpec 3: The new, the old, the goodRSpec 3: The new, the old, the good
RSpec 3: The new, the old, the good
 
Building Quality with Foundations of Mud
Building Quality with Foundations of MudBuilding Quality with Foundations of Mud
Building Quality with Foundations of Mud
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 

Destacado

Unity講座第〇回
Unity講座第〇回Unity講座第〇回
Unity講座第〇回Daiki Hara
 
Cистема развития кластеров Новосибирской области
Cистема развития кластеров Новосибирской областиCистема развития кластеров Новосибирской области
Cистема развития кластеров Новосибирской областиМаксим Марков
 
Types Of Curtains And Draperies,Contemporary Curtains
Types Of Curtains And Draperies,Contemporary CurtainsTypes Of Curtains And Draperies,Contemporary Curtains
Types Of Curtains And Draperies,Contemporary CurtainsPalaksi Kashyap
 
Project Management as a Service
Project Management as a ServiceProject Management as a Service
Project Management as a ServiceSATYAVEER PAL
 
музыкальный день
музыкальный деньмузыкальный день
музыкальный деньvirtualtaganrog
 
TAMK Briefly in English
TAMK Briefly in EnglishTAMK Briefly in English
TAMK Briefly in Englishtamk_uas
 
Series ascendentes con suma de decimales.
Series ascendentes con suma de decimales.Series ascendentes con suma de decimales.
Series ascendentes con suma de decimales.28052809
 

Destacado (9)

Unity講座第〇回
Unity講座第〇回Unity講座第〇回
Unity講座第〇回
 
Negocios inclusivos
Negocios inclusivosNegocios inclusivos
Negocios inclusivos
 
Cистема развития кластеров Новосибирской области
Cистема развития кластеров Новосибирской областиCистема развития кластеров Новосибирской области
Cистема развития кластеров Новосибирской области
 
Types Of Curtains And Draperies,Contemporary Curtains
Types Of Curtains And Draperies,Contemporary CurtainsTypes Of Curtains And Draperies,Contemporary Curtains
Types Of Curtains And Draperies,Contemporary Curtains
 
2015 2016
2015   20162015   2016
2015 2016
 
Project Management as a Service
Project Management as a ServiceProject Management as a Service
Project Management as a Service
 
музыкальный день
музыкальный деньмузыкальный день
музыкальный день
 
TAMK Briefly in English
TAMK Briefly in EnglishTAMK Briefly in English
TAMK Briefly in English
 
Series ascendentes con suma de decimales.
Series ascendentes con suma de decimales.Series ascendentes con suma de decimales.
Series ascendentes con suma de decimales.
 

Similar a Mspec talk

Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1willmation
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
Testing And Mxunit In ColdFusion
Testing And Mxunit In ColdFusionTesting And Mxunit In ColdFusion
Testing And Mxunit In ColdFusionDenard Springle IV
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsChristopher Bartling
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsSalesforce Developers
 
Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Frédéric Delorme
 
Js fwdays unit tesing javascript(by Anna Khabibullina)
Js fwdays unit tesing javascript(by Anna Khabibullina)Js fwdays unit tesing javascript(by Anna Khabibullina)
Js fwdays unit tesing javascript(by Anna Khabibullina)Anna Khabibullina
 
JS Frameworks Day April,26 of 2014
JS Frameworks Day April,26 of 2014JS Frameworks Day April,26 of 2014
JS Frameworks Day April,26 of 2014DA-14
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Deliverymasoodjan
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!Ortus Solutions, Corp
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontendHeiko Hardt
 
Effective Test Driven Database Development
Effective Test Driven Database DevelopmentEffective Test Driven Database Development
Effective Test Driven Database Developmentelliando dias
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
C fowler azure-dojo
C fowler azure-dojoC fowler azure-dojo
C fowler azure-dojosdeconf
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBMichal Bigos
 

Similar a Mspec talk (20)

Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
ASP.NET MVC Extensibility
ASP.NET MVC ExtensibilityASP.NET MVC Extensibility
ASP.NET MVC Extensibility
 
Rhino Mocks
Rhino MocksRhino Mocks
Rhino Mocks
 
Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1Behaviour Driven Development V 0.1
Behaviour Driven Development V 0.1
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
 
Testing And Mxunit In ColdFusion
Testing And Mxunit In ColdFusionTesting And Mxunit In ColdFusion
Testing And Mxunit In ColdFusion
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And Friends
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8
 
Js fwdays unit tesing javascript(by Anna Khabibullina)
Js fwdays unit tesing javascript(by Anna Khabibullina)Js fwdays unit tesing javascript(by Anna Khabibullina)
Js fwdays unit tesing javascript(by Anna Khabibullina)
 
JS Frameworks Day April,26 of 2014
JS Frameworks Day April,26 of 2014JS Frameworks Day April,26 of 2014
JS Frameworks Day April,26 of 2014
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Effective Test Driven Database Development
Effective Test Driven Database DevelopmentEffective Test Driven Database Development
Effective Test Driven Database Development
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
C fowler azure-dojo
C fowler azure-dojoC fowler azure-dojo
C fowler azure-dojo
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDB
 
UI Testing
UI TestingUI Testing
UI Testing
 

Último

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 

Último (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Mspec talk

  • 1. INTRODUCTION TO MSPEC AND OTHER STUFF Edward Wilde
  • 2. A LITTLE ABOUT ME I’M NOT RELIGIOUS AN EXPERT BUT SOME CLIENTS ARE
  • 3. UNIT TESTING Arrange-Act-Assert BASICS a pattern for arranging and formatting code in UnitTest methods: Arrange http://c2.com/cgi/wiki?ArrangeActAssert Arrange all necessary preconditions Act and inputs. Act on the object or method under Assert test. Assert that the expected results have occurred.
  • 4. CODE BREAK DEMO ARRANGE ACT ASSERT
  • 5. BDD WHAT IS IT? TDD with some structure • Test names should be sentences • Tests should be focused • Tracing requirements, executable acceptance criteria
  • 6. STORY Feature: Short clear BASED As an actor of the system TESTING I want to perform some action In order to realize some business value User story Scenario: Some business situation Given some context And some other condition When the actor perform an action Acceptance Then the outcome is achieved Criteria And some other outcome is achieved Scenario: Some other situation related to the same story
  • 7. USER STORY Feature: Account transfer EXAMPLE As a customer I want to transfer money between accounts online In order to avoid having to telephone my bank to carry do this Scenario: Account has required funds Given the source account is sufficient And the customer has signed up to online banking When the customer transfers money between accounts Then the target account is credited immediately And the source account is debited immediately Scenario: Account has insufficient funds Given the source account is insufficient funds...
  • 8. CODE BREAK Creating a BDD test using SPEC FLOW
  • 9. ENTER MSPEC CONTEXT SPECIFICATION FRAMEWORK CONTEXT == ARRANGE or GIVEN SPECIFICATION == ASSERT or THEN DEVELOPER CENTRIC BETTER FOR UNIT TESTING
  • 10. TEST when_describe_context { STRUCTURE Establish context = () Arrange Given Because of = () =... Act When It should_...() =... Assert Then It should_...() =... Cleanup test_data () =... }
  • 11. INSTALLATION Using chocolatey: cinst machine.specifications run InstallResharperRunner.7.1 Resharper live templates Resharper settings – see resources
  • 12. CODE BREAK Creating an mspec test
  • 13. TESTING Behaves_likeTBehavior BEHAVIOR [Behaviors] public class AccountInCredit { protected static Account account; It should_have_a_positive_balance = () = account.Balance.ShouldBeGreaterThan(0m); }
  • 14. CODE BREAK Creating an mspec test using behaviors
  • 15. MACHINE FAKES Integrates machine.specifications and mocking Auto-mocking container Choose between: RhinoMocks, Moq, NSubstitue and FakeItEasy Install-Package machine.specifications.moq
  • 16. MACHINE FAKES WITHFAKES WithFakes Base class giving you access to AnTFake or SomeTFake to create fakes WhenToldTo(x=x.foo).Return(3) // create an expectation WasToldTo(x=x.foo) // verfiy an expectation ParamT
  • 17. CODE BREAK Creating a test using WithFakes
  • 18. MACHINE FAKES WITHSUBJECT WithSubjectT Automocking container Creates subject under test for you TheTinterface access existing fakes
  • 19. CODE BREAK Creating a test using WithSubjectT
  • 20. MACHINE.FAKES REUSING CONTEXT OnEstablish context = fake = { fake .TheIFoo .WhenToldTo(x=x.Bar()) .Return(“Baz”); } OnCleanup sub
  • 21. CODE BREAK Creating a test reusing context setup code.
  • 22. MSPEC ALT SHARPDEVELOP TEAM CITY COMMAND LINE MSBUILD TASK
  • 23. LESSONS I LEARNED Treat test code like production code Use DI and Factories Be wary of inheritance Tests should be simple Don’t be scared to delete tests
  • 24. RESOURCES Machine.Specifications https://github.com/machine/machine.specifications Machine.Fakes https://github.com/machine/machine.fakes Resharper templates http://therightstuff.de/2010/03/03/MachineSpecifications-Templates-For-ReSharper.aspx Resharper settings http://www.thebooleanfrog.com/post/2011/11/24/ReSharper-StyleCop-and-MSpec-All-Together- Now.aspx
  • 25. PROJECTS USING MSPEC Fluent NHibernate http://www.fluentnhibernate.org/ Should Assertion Library http://should.codeplex.com EventStore https://github.com/joliver/EventStore Who-Can-Help-Me https://github.com/jongeorge1/Who-Can-Help-Me

Notas del editor

  1. Nice to see so many people here.This is the first time I’ve given a technical talk, so please go easy on me. On the other hand please also interrupt and throw in questionsIt would be great to have a talk, this isn’t meant to be death by powerpointHaving said that I have 25 slides, almost all of them have no valuable contentTalk is going to cover . Arrange act assert (who here knows that) . Intro to BDD (behaviour driven development) . Quick look at specification and story based testing using specflow, similar JbeHave and RSPec .A fast run through of the major features of the mspec and machine.fakes project
  2. I’m not religious this is just the way I like to program if left to play on my own in the develop sand pitHowever more and more clients are demanding that programmers are fluent in TDD/BBD mspec, specflow or fitnesseI also love tools, passionate about doing things quickly / optimizing Out of interest how many people use nuget?nuget IT’s new in the last say 3 years and has really changed how accessbile open source projects are to .net dev.chocolatey
  3. Good practice for organizing tests.
  4. [Test] public void transfering_money_between_account_with_sufficient_funds_should_credit_target_account() { Customer customer = CustomerFactory.CustomerWithSavingAndCurrentAccount(currentAccountCredit: 0m, savingsAccountCredit: 100m);customer.SavingsAccount.Transfer(customer.CurrentAccount, 100m);Assert.That(customer.CurrentAccount.Balance, Is.EqualTo(100m)); }
  5. Give a bit of background Dan North etc….Test names should be sentencesSelf documenting, most developers write the test name in business language, and should in terms of desired behaviorFocused What do we mean here, well formed assertions beginning with should_..... If you find your tests are getting complicated and don’t fit a simple arrange, act , assert it might be an indication your class is trying to do too much and might need some form of composition. So refactor and test the interaction with the composed class instead
  6. A second fundamental choice made by BDD is how desired behaviour should be specified.And you can see that you have a good fit here with AgileThis is an example template and is based on user story specifications, importantly expressed in business language expressing the desired behaviour and business value achieved.
  7. Writing feature files can be done by anyone! Normally best done by QA or SDET roles
  8. Context specification framework is a fancy way for saying it’s a framework that helps distinguish context and the specification. The context being the arrange And the specificatoin being the assert partThis is what MSPEC does really well.MSPEC supports behaviour driven designBut unlike Spec flow, it doesn’t allow the business to create the specification and is more developer focused.More refactor friendly
  9. Looks funny to begin with Statics Lambda’s but you get used to it in the end
  10. Bare bones you can just use the command lineVisual studio integration with resharper, requires installation
  11. Allows you to encapsulate your assertions, also makes the test more readable.Important to note:Step1 : Create a new class with a behavior attributeStep2 : Define your assertionsStep3 : Create the context variable in the behavior as protected with the same name as the associated test class
  12. Installation via nuget.Provides an integration layer between machine fakes and your mocking layer and also abstracts to some degree which framework you use
  13. A lot of test code an get repetitiveRe-use through composition is normally the best way to go, and this is With (classes allow you to do) using OnEstablish
  14. Treat test code like production codeSame level of respect and rigorUse DI and FactoriesInstantiating objects in test code, is likely to make your tests brittle and a pain to maintainBe wary of inheritanceCan obscure important meaning of your