10. SCIENCE!
•15-30% higher code “quality”
•10-20% longer development
time
http://biblio.gdinwiddie.com/biblio/StudiesOfTestDrivenDevelopment
Thursday, 22 August 13
11. TDD
1: Write a unit test
2: Watch it fail
3: Make it pass simply
4: Refactor
5: Goto 1
Thursday, 22 August 13
16. class InitialGunSetupView : MonoBehaviour
Model View
Controller
class Gun : MonoBehaviour
class GunController
class AmmoView : MonoBehaviour
struct GunModel
TDD
Thursday, 22 August 13
17. 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
20. •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