Articles tagged with Testing

Review of "Python Testing with pytest, Second Edition"

By Eric — 3 minute read

Book Cover

Even though I've been using pytest for years, being a testing enthusiast, I thought I'd read Brian Okken's book to see what I might be able to learn from it. I was pleased to discover not only several tidbits of the workings of pytest I hadn't known about, but also …

Read more...

Randomness in Tests

By Eric — 4 minute read

Wouldn't it be cool if a few uses of the random module in your unit tests could discover bugs in your code? Meh.

The problem is that random tests are non-deterministic, meaning they lack the highly desirable property that if they pass in my local development environment, they'll also pass …

Read more...

The First Rule of Test Code

By Eric

Software is kind of cool in that you can write programs that verify that your other programs work correctly. These testing "meta programs" tend to get short-shrift though, because it's not like the code is actually part of the shipping product. So who cares about cleanliness or good style or …

Read more...

Unit Testing Silverlight View Models

By Eric — 3 minute read

Being relatively new to Silverlight development, I've not had the good sense to accept conventional wisdom that the Visual Studio unit test framework can't be used to test Silverlight code. For testing view models at least, I've been successfully using Mstest and Rhino Mocks for a few months now.

One …

Read more...

Mock Object Strategies

By Eric — 12 minute read

How do you get your production code to use real objects and your test code to use mock objects?

Here's the class we want to test (adapted from Object-Oriented Design Heuristics, Arthur J. Riel):

public class HeatFlowRegulator 
{ 
    private Furnace furnace; 
    private Set house;    

    public HeatFlowRegulator(Set house) 
    { 
        this.house = house …

Read more...

Testing Styles: Favor Unit Testing

By Eric — 8 minute read

Ideally, human efforts in testing should focus on building tests -- figuring out the strategies, test cases, and test data. From there, we'd rather let the computer run the tests and verify the results. If you had to test everything manually every day, you would either not do it, or really …

Read more...