Uma Ghotikar talks about “Fundamentals of Unit Testing, BDD and Mocking (using TestBox and MockBox)” in this episode of ColdFusion Alive podcast with host Michaela Light.
Contents
Show notes
- What is unit testing?
- Test small piece of functionality
- Low level, small scope, a method, a function, a clause
- Why do unit testing
- To validate every part of the app whether the UI is ready or not
- Easier to know where the bug is located
- Faster to run than general user tests, more thorough test coverage of all use cases, easy to automate
- Can write tests before you code
- So know where your code needs to raise an error
- Guidelines to write unit tests
- Fast for immediate feedback (milliseconds) during refactoring and coding
- Avoid database, file system, http and API calls – mock them instead
- Modular – so can reuse the test
- Independent of other unit tests
- Robust – work the same independent of time of day etc
- Keep them up to date
- Clear defined purpose – one piece of functionality
- Clear pre-conditions, actions and expected outcomes
- When you code make sure you can get the test to fail first before you write code to make it pass
- Reactive programming
- Most tests are of code in the Model part of MC
- Fast for immediate feedback (milliseconds) during refactoring and coding
- Why do you like xUnit and BDD styles of testing?
- TDD focuses on testing your low level functions and methods
- Tedious to write all these tests
- BDD checks you satisfy your customer requirements at high level
- User story and scenario
- TDD focuses on testing your low level functions and methods
- What is TestBox?
- Open Source
- The Given – When – Then syntax
- BDD syntax and xUnit
- The general structure for writing unit tests.
- Set up, Tear down phrases
- What is mocking?
- Why do you like MockBox
- Open source
- What is BDD and why do you like it
- High level
- CI
- How do TestBox and MockBox work together for BDD
- Why are you proud to use CF?
- WWIT to make CF more alive this year?
- What are you looking forward to at Into The Box?
Mentioned in this episode
- TDD = Test Driven Development
- BDD = Behavior Driven Development
- xUnit
- TestBox
- CFML slack test channel
- MockBox
And to continue learning how to make your ColdFusion apps more modern and alive, I encourage you to download our free ColdFusion Alive Best Practices Checklist.
Because… perhaps you are responsible for a mission-critical or revenue-generating CF application that you don’t trust 100%, where implementing new features is a painful ad-hoc process with slow turnaround even for simple requests.
What if you have no contingency plan for a sudden developer departure or a server outage? Perhaps every time a new freelancer works on your site, something breaks. Or your application availability, security, and reliability are poor.
And if you are depending on ColdFusion for your job, then you can’t afford to let your CF development methods die on the vine.
You’re making a high-stakes bet that everything is going to be OK using the same old app creation ways in that one language — forever.
All it would take is for your fellow CF developer to quit or for your CIO to decide to leave the (falsely) perceived sinking ship of CFML and you could lose everything—your project, your hard-won CF skills, and possibly even your job.
Luckily, there are a number of simple, logical steps you can take now to protect yourself from these obvious risks.
No Brainer ColdFusion Best Practices to Ensure You Thrive No Matter What Happens Next
ColdFusion Alive Best Practices Checklist
Modern ColdFusion development best practices that reduce stress, inefficiency, project lifecycle costs while simultaneously increasing project velocity and innovation.
√ Easily create a consistent server architecture across development, testing, and production
√ A modern test environment to prevent bugs from spreading
√ Automated continuous integration tools that work well with CF
√ A portable development environment baked into your codebase… for free!
Learn about these and many more strategies in our free ColdFusion Alive Best Practices Checklist.
Session Description:
Topic:
Intro to Unit Testing, BDD and Mocking using TestBox & MockBox
This session will cover the basics such as what is unit testing, why to do unit testing and guidelines to write the unit tests. It will then cover xUnit and BDD styles of testing in TestBox, Given – When – Then syntax and the general structure for writing unit tests. We will then look into the mocking and demo examples of unit testing using TestBox & MockBox.
Podcast: Play in new window | Download | Embed
Subscribe: RSS
Uma Ghotikar Bio
Uma Ghotikar has more than 6 years of experience in web application development, database design and development. She has a technical educational background. She did Master of Science in Information Systems from George Mason University, USA and Bachelor of Engineering in Information Technology from University of Mumbai, India. She enjoys coding especially the back-end development and learning new technical skills.
Links
Interview Transcript:
Michaela 0:00
Welcome back to the show. And today we're looking at the fundamentals of unit testing, be DD, which is behavior driven development and mocking and using test box and Dropbox, do that, and I'm here with Alma Gattaca. And if you don't know her, she is a cold fusion developer been doing it CFL on cold fusion for six years now. And she is giving a talk on this topic at into the box. So we will cover what is unit testing and why everyone listening should be doing it. And guidelines for writing great unit tests. And then also we'll look in detail at test box. And what it lets you do and how to structure unit tests using it will look at what marketing is and how to do that using mock box and why you want to do that. And we'll also look at behavior driven development or BDD and why you should be doing that and how to do it using test box and mock box together. So welcome oma.
Uma Ghotikar 1:00
Thank you. Thank you for having me. I'm glad to be here. Yeah.
Michaela 1:03
So what is unit testing? For those few people listening? who may not know? Yeah,
Uma Ghotikar 1:10
so yeah, so you're testing is a level of software testing, where, you know, individual units are components of a software testing. And what that means is, the unit is the smallest piece of functionality that can be tested in isolation. So having said that, they are definitely low level they are, they are of small scope. And in procedural language, it could be a function, it could be a method and an object oriented language, it could be a class, our method belongs to a class. So basically, it's the smallest piece of functionality, that's what unit is. And the entire purpose of unit testing is to validate that the each unit of software is performing as design. So that's why we should do unit