Test Driven Developer
You got a TEST for that?
Home
|
Syndication
|
Sign In
Monday, February 15, 2010
Testable Code
What is "testable" code? How do I know if my code is "testable" or not? There is a lot of talk in agile teams about making sure we have testable code, so what exactly does that mean? I will try to explain here some of the things that make code testable.
TDD Methodology
If we are using test-driven development to write the code, it is inherently testable since the tests drove us to write it. However, it is still possible that over time, refactoring can be done in such a way to make it less so. This is not likely however since all the unit tests would be passing.
Dependencies
If the code requires so many external dependencies that we must essentially spin up large parts of the system to test it, this is a clear red flag for testability. We should be able to mock out dependencies and isolate the code under test. If we can't do that, it's not testable. Our dependency relationships should be reasonable and sensible. If there is a "smell" here it probably means that there's work to do to make it testable.
Internal States
If there are lots of internals and complex states without interfaces to access and manipulate them, this is another red flag that the code's not testable. If there is a lot of internal logic and things that happen based on state, this should all be unit tested. If there's not a unit test for each thing that goes on internally, it's not testable. Here again if code is written using TDD this usually doesn't become a problem.
Setup
If the code requires a large amount of setup code to test it, this again is another red flag. I look at the amount of effort it takes to validate that a class does the one thing it's supposed to do. If the test code is more than the main code, it's probably a sign that it's not very testable. Databases are notorious for this issue. I have some database code that's a good example of this concept. The amount of code and data needed to get the database to the state to exercise the few procedures there greatly exceed the code itself. This is kind of combining both the dependencies and internal state concepts, and I think it's definitely not very testable.
Testability is a goal we strive for, it helps us to be able to make sure the code operates successfully and is maintainable. Write good unit tests. Look for testability in the small, and that will help the overall system to be more testable as well.
Monday, February 15, 2010 8:21:07 AM (Pacific Standard Time, UTC-08:00)
Comments [2]
|
Thursday, February 25, 2010 3:24:33 AM (Pacific Standard Time, UTC-08:00)
Hi I am newly using Selenium.Now I writing Selenium command via tcl.I have some doubts in selenium.
I tried following commads in Selenium but its not working please help this issue
Se dragAndDrop "link=tn00607a.gif (1499 bytes)" "400,600"
DragAndDrop is not working in selenium.please help this issue
Se contextMenu "link=README"
I didn't see any Contextmenu option in my testing web page.but i didn't get any error in console
Like that mouseDown,mouseMove,museUp commands also not visible in web page.
If user clicks new link in home page and can't go to the home page.So avoid this problem I used goBack method
Se goBack
like that How to I forward the page.please help me.
How to hanle filedownload option via selenium with TCL.please help this issue
yuvaarajj
Thursday, February 25, 2010 9:06:57 AM (Pacific Standard Time, UTC-08:00)
It's been some time since I used Selenium DragAndDrop. I did all my work in C# using the Microsoft .NET implementation, and I am not familiar with TCL. Can you implement it in java or some other language perhaps? i am certain that the java and .NET libraries are much more widely used and probably have better testing and support. Also if it's possible, get ID's into your tags that are the targets of actions. not only does it make the coding easier, but it's more robust in the long term.
John Boal
Comments are closed.
© Copyright 2010, John E. Boal
Calendar
<
July 2010
>
Sun
Mon
Tue
Wed
Thu
Fri
Sat
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
Total Posts: 44
This Year: 4
This Month: 0
This Week: 0
Comments: 22
Archives
June, 2010 (1)
April, 2010 (1)
March, 2010 (1)
February, 2010 (1)
September, 2009 (1)
August, 2009 (1)
June, 2009 (1)
May, 2009 (1)
April, 2009 (1)
February, 2009 (1)
January, 2009 (2)
December, 2008 (2)
November, 2008 (2)
October, 2008 (2)
September, 2008 (4)
August, 2008 (3)
July, 2008 (5)
June, 2008 (4)
May, 2008 (1)
April, 2008 (2)
March, 2008 (4)
February, 2008 (2)
January, 2008 (1)
On this page
categories
ABN
Acceptance Criteria
ATDD
Automation
Bugs
C#
Continuous Integration
Mocks
MSTest
Python
Refactoring
Selenium
SQL
TDD
Testing
Tools
Unit Tests
Video
WatiN
Links
Home
Test Driven Development, Defined (Wikipedia)
Test Driven Design
Test-Driven.com - Agile development tools
NUnit
Book: Test-Driven Development in Microsoft .NET
CodeProject - Advanced Unit Testing: Unit Test Patterns
John Boal's Personal Blog
John Boal's Agile Development Blog
Blogroll
OPML
Lazy Coder
Scott Koon's Blog
#2782
Ade Miller's Tech Blog
Agile Development
Mitch Lacey's Agile Development Blog
Espresso Fueled Agile Development
Mike Puleio's Blog
Geek Noise
Noise de Peter Provost
Sneal's Blog
Shawn Neal's Blog
Search
About
© Copyright 2010, John E. Boal
Sign In