SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
Unit Testing
and
Test-Driven
Development
In Unity3D
Thursday, 22 August 13
Definitions
Thursday, 22 August 13
Test
“Automated code that
invokes a system and checks
behaviour.”
Thursday, 22 August 13
Unit Test
“Checks a single
assumption about the
behavior of one system.”
Thursday, 22 August 13
Integration
Test
“Checks multiple systems
are correctly connected”
Thursday, 22 August 13
Unit Test != Integration Test
Only fails when target
assumption fails
Fails when one of multiple
implicit assumptions fail
Thursday, 22 August 13
Qualities of a Unit Test
Readable
Maintainable Trustworthy
Thursday, 22 August 13
[Test]
void UpdatePath_OneActionChild_AddsSelAndChildToPath() {
var actionNode = FakeAction.CreateStub();
m_selNode.AddChild(actionNode);
m_selNode.UpdatePath(m_path, NodeResult.Fails, null);
var desiredPath = new ITreeNode[] {
m_selNode, actionNode };
Assert.IsEqualSequence(m_path, desiredPath);
}
Thursday, 22 August 13
Test Driven
Development
Thursday, 22 August 13
SCIENCE!
•15-30% higher code “quality”
•10-20% longer development
time
http://biblio.gdinwiddie.com/biblio/StudiesOfTestDrivenDevelopment
Thursday, 22 August 13
TDD
1: Write a unit test
2: Watch it fail
3: Make it pass simply
4: Refactor
5: Goto 1
Thursday, 22 August 13
Demo
Thursday, 22 August 13
TDD and Unity3D
Thursday, 22 August 13
NON-TRIVAL
No post-
compile hook
MonoBehaviours are
un-unit-testable
Lots of alt-
tabbing
Thursday, 22 August 13
Model View
Controller
MonoBehaviour View
Game code Controller
Struct data Model
Thursday, 22 August 13
class InitialGunSetupView : MonoBehaviour
Model View
Controller
class Gun : MonoBehaviour
class GunController
class AmmoView : MonoBehaviour
struct GunModel
TDD
Thursday, 22 August 13
Model View
Controller
class Gun : MonoBehaviour {
public GunModel Model { get; private set; }
void Awake() {
Model = new GunModel();
m_controller = new GunController(Model);
class AmmoView : MonoBehaviour {
void Awake() {
m_model = GetComponent<Gun>().GunModel;
Thursday, 22 August 13
Dependency
Injection
public void GunController(GunModel model, IWorldPhysics physics) {
Physics = physics;
Model = model;
}
Thursday, 22 August 13
Recap
Thursday, 22 August 13
•Unit tests test only one thing
•Readable, maintainable, trustable
•SCIENCE says TDD is e!ective
•Write test, see fail, make pass, refactor
•Model-View-Controller and Dependency Injection
make TDD possible in Unity
•Kent Beck, “Test Driven Development”
•Roy Osherove, “Art of Unit Testing”
•UnTest http://www.github.com/tenpn/untest
•Moq https://www.nuget.org/packages/moq
•StrangeIOC http://thirdmotion.github.io/
strangeioc/
Andrew Fray, @tenpn, andrew.fray@gmail.com
http://andrewfray.wordpress.com
Thursday, 22 August 13

Weitere ähnliche Inhalte

Was ist angesagt? (20)

TestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaTestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | Edureka
 
TestNG Data Binding
TestNG Data BindingTestNG Data Binding
TestNG Data Binding
 
TestNg_Overview_Config
TestNg_Overview_ConfigTestNg_Overview_Config
TestNg_Overview_Config
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
Test ng for testers
Test ng for testersTest ng for testers
Test ng for testers
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit framework
 
TestNG
TestNGTestNG
TestNG
 
Test ng tutorial
Test ng tutorialTest ng tutorial
Test ng tutorial
 
Test NG Framework Complete Walk Through
Test NG Framework Complete Walk ThroughTest NG Framework Complete Walk Through
Test NG Framework Complete Walk Through
 
Test ng
Test ngTest ng
Test ng
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 
Unit testing
Unit testingUnit testing
Unit testing
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit Testing
 
Automation test
Automation testAutomation test
Automation test
 
Test doubles
Test doublesTest doubles
Test doubles
 
Unit testing
Unit testingUnit testing
Unit testing
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Grails Spock Testing
Grails Spock TestingGrails Spock Testing
Grails Spock Testing
 

Andere mochten auch

Remote Working at Spry Fox
Remote Working at Spry FoxRemote Working at Spry Fox
Remote Working at Spry FoxAndrew Fray
 
Practical unit testing GDC 2014
Practical unit testing GDC 2014Practical unit testing GDC 2014
Practical unit testing GDC 2014Andrew Fray
 
Javascript TDD by example
Javascript TDD by exampleJavascript TDD by example
Javascript TDD by exampleEric Mignot
 
Java script tutorial by example
Java script tutorial by exampleJava script tutorial by example
Java script tutorial by examplemyzyzy
 
Mock driven development using .NET
Mock driven development using .NETMock driven development using .NET
Mock driven development using .NETPuneet Ghanshani
 
[Pl in c++] 10. battleship game 5
[Pl in c++] 10. battleship game 5[Pl in c++] 10. battleship game 5
[Pl in c++] 10. battleship game 5MinGeun Park
 
[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성MinGeun Park
 
[Pl in c++] 5. 객체지향 프로그래밍
[Pl in c++] 5. 객체지향 프로그래밍[Pl in c++] 5. 객체지향 프로그래밍
[Pl in c++] 5. 객체지향 프로그래밍MinGeun Park
 
Software testing vs. Game testing
Software testing vs. Game testingSoftware testing vs. Game testing
Software testing vs. Game testingJohan Hoberg
 
[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들
[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들
[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들MinGeun Park
 
[141015] cedec 2014 참관기 & 강연 리뷰 #2
[141015] cedec 2014 참관기 & 강연 리뷰 #2[141015] cedec 2014 참관기 & 강연 리뷰 #2
[141015] cedec 2014 참관기 & 강연 리뷰 #2MinGeun Park
 
[Pl in c++] 12. learning
[Pl in c++] 12. learning[Pl in c++] 12. learning
[Pl in c++] 12. learningMinGeun Park
 
[141004] cedec 2014 참관기 & 강연 리뷰 #1
[141004] cedec 2014 참관기 & 강연 리뷰 #1[141004] cedec 2014 참관기 & 강연 리뷰 #1
[141004] cedec 2014 참관기 & 강연 리뷰 #1MinGeun Park
 
Top 10 games tester interview questions and answers
Top 10 games tester interview questions and answersTop 10 games tester interview questions and answers
Top 10 games tester interview questions and answerscaitlinkelly433
 
Introduce Game Testing And QA
Introduce Game Testing And QAIntroduce Game Testing And QA
Introduce Game Testing And QAPham Anh Tuan
 
[SCON9] 커뮤니케이션 in Game
[SCON9] 커뮤니케이션 in Game[SCON9] 커뮤니케이션 in Game
[SCON9] 커뮤니케이션 in GameMinGeun Park
 
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기MinGeun Park
 

Andere mochten auch (20)

Tdd in unity
Tdd in unityTdd in unity
Tdd in unity
 
Remote Working at Spry Fox
Remote Working at Spry FoxRemote Working at Spry Fox
Remote Working at Spry Fox
 
Game testing
Game testingGame testing
Game testing
 
Practical unit testing GDC 2014
Practical unit testing GDC 2014Practical unit testing GDC 2014
Practical unit testing GDC 2014
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Javascript TDD by example
Javascript TDD by exampleJavascript TDD by example
Javascript TDD by example
 
Java script tutorial by example
Java script tutorial by exampleJava script tutorial by example
Java script tutorial by example
 
Mock driven development using .NET
Mock driven development using .NETMock driven development using .NET
Mock driven development using .NET
 
[Pl in c++] 10. battleship game 5
[Pl in c++] 10. battleship game 5[Pl in c++] 10. battleship game 5
[Pl in c++] 10. battleship game 5
 
[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성
 
[Pl in c++] 5. 객체지향 프로그래밍
[Pl in c++] 5. 객체지향 프로그래밍[Pl in c++] 5. 객체지향 프로그래밍
[Pl in c++] 5. 객체지향 프로그래밍
 
Software testing vs. Game testing
Software testing vs. Game testingSoftware testing vs. Game testing
Software testing vs. Game testing
 
[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들
[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들
[141217 박민근] Visual Studio 2013의 (잘모르는) 유용한 기능들
 
[141015] cedec 2014 참관기 & 강연 리뷰 #2
[141015] cedec 2014 참관기 & 강연 리뷰 #2[141015] cedec 2014 참관기 & 강연 리뷰 #2
[141015] cedec 2014 참관기 & 강연 리뷰 #2
 
[Pl in c++] 12. learning
[Pl in c++] 12. learning[Pl in c++] 12. learning
[Pl in c++] 12. learning
 
[141004] cedec 2014 참관기 & 강연 리뷰 #1
[141004] cedec 2014 참관기 & 강연 리뷰 #1[141004] cedec 2014 참관기 & 강연 리뷰 #1
[141004] cedec 2014 참관기 & 강연 리뷰 #1
 
Top 10 games tester interview questions and answers
Top 10 games tester interview questions and answersTop 10 games tester interview questions and answers
Top 10 games tester interview questions and answers
 
Introduce Game Testing And QA
Introduce Game Testing And QAIntroduce Game Testing And QA
Introduce Game Testing And QA
 
[SCON9] 커뮤니케이션 in Game
[SCON9] 커뮤니케이션 in Game[SCON9] 커뮤니케이션 in Game
[SCON9] 커뮤니케이션 in Game
 
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
[150124 박민근] 모바일 게임 개발에서 루아 스크립트 활용하기
 

Kürzlich hochgeladen

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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
 
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
 
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
 
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
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Kürzlich hochgeladen (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
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
 
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)
 
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...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Unit Testing and Test Driven Development in Unity3D