Feb
22

Definitely Not Cool

Some features are not sexy, nor cool.

But we need them. Many of the features we’re adding to Isolator come from the needs of our development team. It is usually the case that if our team needs a solution, others do as well. And this one plagued us  and our customers from the beginning.

There can’t be only one

The way Isolator was built, it was not possible to have only one version installed on the machine. That required project upgrades with each version. But that became a problem overtime, usually in CI server environments. As long as you have only one team, and they all use the same version. Upgrades is something everybody does together.

This becomes quite an organizational headache in large teams. And then you have projects that have require different versions on the same build machine. We’ve added the auto-deploy feature for the server, but that wasn’t enough. It required too much maintenance.

And like I said, this wasn’t a problem just for customers. It was an internal issue as well. A developer needs to develop a new feature on V next, while checking support issues on different versions, because that’s how we roll.

We decided to solve the problem in Isolator V7: We wanted to run projects with older (or newer) versions, with minimal intervention. The big challenge was older versions: How do we make old versions run, if we can’t change them? Our time machine has been broken for a while…

But we did it.

From V7 on, you’ll be able to run projects that reference old version of Isolator as old as version 5.2.3 (there was a bug in prervious versions we couldn’t overcome), on the same machine that have tests compiled with the new versions.

That means that once you install V7 on a client or a server machine, and you have test projects with any other versions, all you need are the reference dlls for that version locally. Everything else will take care of itself. Every server operation you already have (command lines, tasks, auto-deployment) will work as before – No need to change anything you’re doing.

Some features are not sexy, nor cool.

They just make life easier.

Want to know more about V7? Join me in the webinar to see what’s coming.

Permanent link to this article: http://www.typemock.com/blog/2012/02/22/definitely-not-cool/

Feb
20

Discover A New Perspective on Unit Testing – Isolator V7

Want to learn the secrets of Typemock’s newest solution: Isolator V7.

Isolator V7 puts a whole new perspective on unit testing. It will make unit testing much easier and help you catch more defects and help your company release their software faster.

Check it out!

Typemock Isolator V7 provides:

  • Immediate feedback of newly introduced bugs with a new autorunner.
  • Pinpoint identification of the bug’s location with the failed-test analyzer.
  • Visual coverage of which part of your code is covered
  • Powerful mocking, guaranteeing that you can write tests for any code, whether new code or legacy code
  • Industry integration with major development tools


Join in the webinar and receive a free beta license. Be the first to try it out.

When: Wednesday, February 22 at 10:00 AM ET, 14:00 GMT, 20:30 India

To Sign Up: http://bitly.com/wRBhZc

Permanent link to this article: http://www.typemock.com/blog/2012/02/20/discover-a-new-perspective-on-unit-testing-isolator-v7/

Feb
14

The Opposite of Mocking

Let me tell you a secret. I don’t like the word “mocking”.

Why?

Because “mocking” refers to the tools we use, rather than what we want to achieve, which is isolation. However, I’ve decided to let this one go a few years back due to public acceptance of the term.

Still, this word has impacted how we’re using mocking (see?) frameworks to this day. You can see that in the APIs. Even in Isolator, we used “Fake” to tell the system to create fake objects, instead of just telling the code-under-test to isolate itself.

Until now.

In Isolator V7 we introduce a new API called Isolate.Fake.Dependencies. Here’s an example for a class under test:

public class UnderTest
{
     public int someField;
     public UnderTest anotherInstance;
     public IInterface iInterface;

    public UnderTest(int a, UnderTest nextInstance, IInterface x)
{
         this.someField = a;
         this.anotherInstance = nextInstance;
         this.iInterface = x;
}
}

What’s the simplest case of isolation? Faking the dependencies injected through the constructor, of course! Sure, I can use the regular APIs to create fakes, and initialize the object with them. Or I can use the new API:


[TestMethod]
public void FakeDependencies_FakesAllDependencies()
{

     UnderTest underTest = Isolate.Fake.Dependencies<UnderTest>();

  Assert.AreEqual(0, underTest.someField);

    Assert.AreSame(Isolate.GetFake<iInterface>(underTest), underTest.iInterface);

    Assert.AreSame(Isolate.GetFake<UnderTest>(underTest), underTest.anotherInstance);

}

Why would I use the fake dependency? To set behavior. Or verify method behavior. For example:

[TestMethod] public void FakeDependencies_UseWhenCalled()

{      

     UnderTest underTest = Isolate.Fake.Dependencies<UnderTest>();   

     Isolate.WhenCalled(() => Isolate.GetFake<IInterface>(underTest).ReturnSomething()).WillReturn(40);

     Assert.AreEqual(40, underTest.iInterface.ReturnSomething());

}

In this case I use WhenCalled-WillReturn to specify behavior for the ReturnSomething method.

What happens if I decide to take out either the first or second argument from the constructor? The test still works!

It makes tests more concise and readable, and more robust, because there’s less explicit things to break.

I guess we’re not done with all the “mocking” metaphors. But it’s a step in the right direction.

And it’s part of our new perspective on unit testing.

Want to learn more? Join our webinar about Isolator V7 and be the first to try it out. Join in!

Permanent link to this article: http://www.typemock.com/blog/2012/02/14/the-opposite-of-mocking/

Feb
13

Webinar: Testing Untestable Legacy Code

How do you apply unit testing to existing code? Code that wasn’t meant to testing and normally breaks when testing?

Legacy code is FUN!

This is a hardcore session, where we take an open source application and add tests to it. In the process, we’ll refactor the code, discuss readability, and where to even begin.

This is an intensive demonstration of automated testing hard-core legacy code. If you are a legacy ninja, check it out.

Everyone is welcome but it is most appropriate for advanced background with previous experience in unit tests. Examples are in .NET but everyone is welcome. If you’re a unit testing ninja, this webinar is for you!

When: Wednesday February 15 at 10:00 AM ET / 3:00 PM GMT (UK) / 8:30 PM India

To sign up: https://www2.gotomeeting.com/register/359715538

Permanent link to this article: http://www.typemock.com/blog/2012/02/13/webinar-testing-untestable-legacy-code/

Feb
08

Isolating Code: A Quick Intro to Typemock Isolator

Dustin Davis recently started using Typemock Isolator and has reviewed it on his site.

According to Dustin, “the point is to isolate methods. TypeMock Isolator makes this pretty easy. Mocking frameworks have come a long way in the last 2 years and TypeMock is pretty impressive.”

Permanent link to this article: http://www.typemock.com/blog/2012/02/08/isolating-code-a-quick-intro-to-typemock-isolator/

Feb
07

The Most Controversial Feature in Isolator V7

You thought that was controversial...Michael Feathers posted about “Taking Automated Tests Off The Pedestal”. The post generated quite a discussion, which really revolved around the time it takes to run tests in established teams. Michael talks about how the number of tests grows larger, and that the related time needed to run these tests becomes a “yoke around their neck”. But teams continue to put the effort into writing more tests, because of the perceived cost of not covering features.

Eventually, Michael suggests that we evaluate the feedback value we get from tests, and maybe put a limit on how much quickly we get this feedback. If we’re over the limit, we should sacrifice coverage for the sake of feedback. As Michael said: quite controversial.

I agree.

One of the principles guiding us with Isolator V7 is the idea of immediate feedback. That’s, after all ,what unit tests are all about.

The problem of course, is that not all unit tests are really “unit tests”. If you are experienced enough, they might be. But unit testing is an acquired skill, and as such, you may not write quick tests right at the start. Or you may combine some quick tests with long running tests. These long running tests can add up for a large inexperienced team. And when they get experienced, they are already stuck with the long running test suite.  How do you get immediate feedback?

We decided to take the controversial step.

Right at the beginning when we started building our auto-runner we understood that we can’t rely on tests running automatically for a short time. So we decided that if tests take longer than 5 seconds, the runner moves on to the next test, and excludes them from further automatic runs. You want to run them? go to the test and run it manually. Or run all the tests manually.  But they are out of the automatic loop.

Like Michael said:  controversial.

We know that in order to take the experience of unit testing to the next level, we should maximize the value we get from it. And the value of unit tests is immediate feedback. The rest of the tests are nice to have also, but should not impede our flow. The more unit tests you write, you get better coverage and feedback, which are their value.

Isolator V7 has some more punch in it.

Stay tuned.

Permanent link to this article: http://www.typemock.com/blog/2012/02/07/the-most-controversial-feature-in-isolator-v7/

Feb
06

The Problems with Unit Testing Frameworks

Unit testing is essential in order to ensure that your code does what it’s supposed to do.

But, as much as Typemock is a firm believer in unit testing, well, let’s be honest — it’s not fun.

As our CEO recently put it in Dr. Dobbs, “Unit testing is like staying healthy,” argues Lopian. “Staying healthy requires best practices such as eating right and working out. Similarly, development teams need the right practices in order to innovate faster. Just as it’s hard to start working out, many find it’s hard to unit test and thus stop — despite its well-known benefits”

But unit testing frameworks have many problems.

Some of them include:

1. Lack of Automation – Yes, you can write manual tests and do everything manually. You can also code in Notepad or another text editor. For some, that’s fine – witness the text editor wars in Linux – but others prefer a robust IDE and toolkit. Automatic unit testing saves time, allows for more robust testing,  and allows for tests to be run repeatedly. But even many automatic unit testing frameworks, like xUnit, or mocking-only frameworks don’t let you test much of your code unless you go 100% by the book with excellent design. Most of us simply don’t have code that can be adequately tested by even the most robust open-source frameworks, leaving us (and our business or product) vulnerable to bugs and technical debt.

2. Focus on test instead of code – The goal is working code, delivered on time. But, too often we forget this, focusing on our tests. But, this allows a disconnect between our test and our code. When a test fails, what does that mean for my code? When it passes, how do I translate that into working software?

Frequently, while we know that a test failed, we don’t always know where the error is. This makes it harder to achieve our goal – getting code out in time that just works.

3. Takes too much time – In our high-stakes development environment, frequently understaffed and overloaded, every second counts. Sometimes, we’re also tempted to shortcut now and save time up front – of course we’ll pay for that later but later is abstract when your boss is breathing down your throat. And, yes, even when you have the luxury of doing TDD by the book on greenfield code, it still takes time up front (of course it will save you time overall, but when the release is due, try telling that to your boss).

Currently, most unit testing frameworks run your entire code every time you make a minor change. If you’ made a minor change, you still need to rebuild your code from scratch. That’s time that you just don’t have when your code is overdue. Each change takes time and seconds turn into minutes and hours.

Frameworks need autocomplete – shaving time – and to just run the code that changed.

4. Weak mocking – Require TDD and good design first – can’t deal with legacy code – Simple greenfield code is a nice fantasy but it’s not most projects. What is needed is a framework that can mock complex legacy code, privates, statics, etc. Most frameworks don’t offer powerful mocking or the ability to test legacy code, new code, or even unwritten code.

5. Coverage – Too many frameworks don’t let you know what’s covered and what’s not. Yes, as Uncle Bob said, coverage is not the most important or only metric and 100% code coverage may not always be the ideal.

But, too often, we don’t know what code is covered and what code is insecure.

 

Leave a comment – what are some things you find lacking with unit testing frameworks. Feel free to tweet as well using hashtag #tddfail

 

It’s time for a change.

Luckily, change is coming.

Stay Tuned TV

Stay tuned.

Can’t wait? Discover unit testing tools and practices this Wednesday and enter the raffle to win an Isolator license.

Want more webinars? Sign up!

Permanent link to this article: http://www.typemock.com/blog/2012/02/06/the-problems-with-unit-testing-frameworks/

Feb
05

Testing Dependencies and Legacy Code

Typemock is hosting a webinar about how to test dependencies and legacy code. The webinar will be on Wednesday February 8 at 8:30 PM (20:30) India Standard Time.

You may have already started unit testing or at least understand the basics. But there’s one large obstacle that stands in your way: dependencies. Most code was not written to be easy to test. How can you test dependencies? Join this webinar and learn different methods and tools that help create unit tests to test dependencies and legacy code.

Living With Legacy Code

Learn:

• Why you are writing legacy code

• Hand rolled mocks

• Mocking frameworks

• What makes a good unit test

This webinar is intended for .NET developers interested in automated unit testing who want to learn how to develop better code.

You can also win a Typemock Isolator license or t-shirt. You must attend for the chance to win

To sign up: http://www.typemock.com/unit-testing-dependencies-and-legacy-code

Permanent link to this article: http://www.typemock.com/blog/2012/02/05/testing-dependencies-and-legacy-code/

Feb
01

Coming Soon: A New Perspective in Unit Testing

Want a sneak peek at what’s coming up in our labs?

Want to learn more, stay tuned for upcoming webinars in February.

Permanent link to this article: http://www.typemock.com/blog/2012/02/01/coming-soon-a-new-perspective-in-unit-testing/

Jan
31

Unit Testing State of the Union

It’s that time of year when the US president gives the annual State of the Union. Since Mr. Obama did not mention unit testing, (I suspect because of homeland security issues) I thought I’d give you my view of where unit testing is in the beginning of 2012.XXXStateOfTheUnion

  • Unit testing and TDD are getting traction. More people understand the value, and more developers see that testing is part of what makes them professional.
  • Unit testing has a wide acceptance across technologies. Developers who unit test, do it across languages.
  • More and more, we regard unit testing as a skill, rather than a development methodology. As any skill it is learned, experienced, improved and mastered. Some people go all the way, some people start and turn back, never to return.
  • Mastering unit testing requires discipline. Discipline begets professionalism. Those things go together, and why you’ll find both traits in successful developers.
  • A lot more people do not unit test than those who do. That’s because unit testing is still hard. The tools are mostly there (depending on the technology and language). Successful developers do not just master tools, but also apply their experience on how to write tests, organize them and maintain them. This is not taught anywhere, and most developers don’t have the mentors, drive or discipline for the long haul.
  • In many organizations that unit test, it’s not really wide spread. A few teams do it, the rest don’t. In order to do an organizational change, you’ll need the skilled people in place to drive the rest of the teams. Since there aren’t many of those around, the organization adoption is very slow.

So what’s next?

The slow adoption rate will change based on two things: better tools that make it easier to test and fix bugs, and the availability of many people to drive teams toward adoption. Typemock will drive the first part (I’ve already alluded to new features in Isolator V7 and that’s just the beginning) but the community needs to do the evangelizing and education that will get more people into the unit testing circle. With more people around we can turn the trickle into a torrent.

And then nobody will have bugs! But I’ll leave that to next year’s State of the Union.

Beg to differ? Write down you’re assessments and predictions in the comments!

Permanent link to this article: http://www.typemock.com/blog/2012/01/31/unit-testing-state-of-the-union/

Older posts «