Browsing all articles in Product
May
19
Comments

Mocking frameworks – dream feature

Author Eli Lopian    Category .NET Tests, Product, TDD     Tags

imageThere are some developers SHOUTING, that mocking static and  non-virtual methods is a big No-No. Roy, is calling them dogmatic.

Come on guys, the most requested feature from Rhino.Mocks is the ability to mock non-virtual and static members, and Oren has even implemented these when possible (MarshalByRef Objects). I am sure that if it was easy, Daniel would do so too.

In other languages where objects can be swapped without Dependency Injection, there is no-one, calling these features – Bad Practice, just the opposite. They are called ‘Power features’, because that is what they are.

You might prefer to sweat and spend a lot of your time figuring out how to make your code testable, and you might find it easier in your company to introduce a free tool, but please, don’t call a tool that gives you lot of pain,  forces you to use DI (even if you don’t really need it) and to spend time creating utterly useless wrappers – a feature!

May
16
Comments

Typemock Isolator 4.2.4 is available

Author Eli Lopian    Category Product, Release     Tags

Typemock Isolator 4.2.4 is available for download.
This is a patch release with many bug fixes.

  • “Invalid Operation Exception” when working with NHybernate and XML serialization was fixed.
  • Complex LINQ queries are now mocked correctly.
  • Manual assembly loading does not cause an exception. AssemblyResolve event fires correctly.
  • RepeatAlways now works correctly following WhenArgumentsMatch.
  • Returning values of types that inherit from generic type now work correctly.
  • GetMocks return the correct mocks for abstract classes and interfaces.
  • Following undeploy Typemock Isolator remains registered.
  • Methods up to 30 parameters can now be mocked.

Get the juicy development information here

Apr
15
Comments

ASP.NET Unit Testing just got Easier

Author Eli Lopian    Category Product, Release     Tags

There is a lot of talk about unit testing ASP.NET. Artem Smirnov  has managed to build a new tool for writing unit tests for ASP.NET. The tool called Ivonna is available as a beta release.

Ivonna is built on top of the Typemock Isolator framework and facilitates running unit tests in the same process as any other unit test, on the client machine, as well as having a specialized API

To start using, see the Getting Started page on the cool site that Artem built. Artem is kind enough to add a forum for feedback – Please use it.

I am sure that there are other packages that can be built for other component to help simplify unit testing, feel free to contact us and we will help you develop these packages

Feb
27
Comments

Typemock and .NET 1.1

Author Eli Lopian    Category Product, Release     Tags

Although we still have many developers using Typemock in .NET 1.1, now that .NET 3.5 is out, we are going to drop the support for .NET 1.1. in our next version.

Version 4.2 will be the last version to support .NET 1.1. This will allow us to support better .NET 2.0+ features and support better type-safe programming.

Any objections?

Feb
6
Comments

Typemock Isolator – Beta – Better Community

Author Eli Lopian    Category Product, Release     Tags

The Typemock team has released our next version of TypeMock.NET.image

We are calling it Typemock-Isolator. As Typemock helps developers Isolate their code from the rest of the system and make it Testable.

The main reason behind this are our plans to create more tools that will help simplify writing unit tests.

The Brain-Storming sessions behind this name where fun and we actually decided on a name, coded it in and then changed the name a few times after that (talk about agile teams). But the team took these changes really well!

Roy and Paulo have already talked about some new features.
Mainly Better Debugger Integration and Mocking Fields!!!

We have decided to add more features to our Community Edition and some features that were in the Professional Edition and can now be used in the Community Edition

  1. Mocking using Generic Code Sugar
  2. Mock mockControl = MockManager.Mock<ClassToMock>();

     

  3. Integrated Visual Studio Help can now be downloaded by all Typemock-Isolator users
  4. Per your request*: The annoying feedback screen while in evaluation, has been removed.

 

* The majority of feedbacks we received was to remove the Feedback Screen ;-)

Dec
26
Comments

Debugging Mocked Methods

Author Eli Lopian    Category Product, Reviews     Tags

Although strict XP practices, value tests more then debugging, there are many cases where you still have to debug the code base to find defects. Doing this with mocked objects can be very fishy.

Evaluating Mocked Properties

When evaluating methods and Properties in the Debugger, the Debugger Hi-Jacks the running application to run the code that evaluate the values. A mocking framework doesn’t know that you are running in the debugger and will return the mocked value. This might cause the test to fail, because of unexpected calls or different return values.

Breaking While Recording

When in Natural Mocks recording block, breaking inside the block will lead to very strange results. This is because the Hi-Jacked threads that are evaluating Properties are being recorded and mocked. The current workaround is to turn off automatic property evaluation.

Debugging Mocked Methods

When stepping into a mocked method, or putting a break point on it, you will never reach the break point. This is because the method is mocked and is never actually run. This is very confusing and I have heard some developers spending a lot of time trying to understand what is happening.

Preview

These issues have been a major feature of our coming TypeMock version and will all be solved.

  • Mocked Property and Method Evaluation will not change the test!
  • Breaking in the Recording Block will nor mess up the recording!
  • There is a visual cue that will allow you to see that the method is mocked.

Example of debugging a mocked method.

 image

As you can see, it is very easy to see that the method is mocked and understand why you cannot step into the method.

What do you think of the visual cue?

We are thinking about adding more information to the editor

  • Return Values
  • Conditional Returns (based on arguments)
  • Different instances

What other information would you like to know while debugging?

Oct
31
Comments

The Ultimate Proof for TypeMock

Author Eli Lopian    Category Product, Reviews     Tags

When developer using TypeMock find it an indispensable tool, it is a sign that we really help ease the task of building lasting software.

Karell says it better:

The best way to see if you need something is to stop using it (or be prevented from using it) for a while and see if you reach out for it out of habit….

I quickly realized that TypeMock.NET had become such an important part of my testing process that I could no longer function without it. It is an indispensable tool and while I acquired another Mock tool I simply can’t do without TypeMock.NET.

Oct
12
Comments

Mocking Extension Methods

Author Eli Lopian    Category Product, TDD     Tags

With Orcas and TypeMock 4.1 you can now mock Extension methods, easily.

Suppose we added a new method to int that return the Roman Number equivalent of that number:

public static class Extend { public static string RomanNumber(this int number) { // do complex logic return romanString; } }

Now we use this method in our code

string romanNumber = 2010.RomanNumber();

Here is how we mock this.

Reflective Mocks (Community Edition)

We mock that actual static extension method

Mock extentionMethodMock = MockManager.Mock(typeof(Extend)); extentionMethodMock.ExpectAndReturn("RomanNumber","MCMLIX");

Natural Mocks (Professional Edition)

We just call the extension method

using (RecordExpectations rec = new RecordExpectations()) { rec.ExpectAndReturn( 2010.RomanNumber(), "MCMLIX"); }

Checking Arguments

Care should be taken when Checking Arguments as the first argument is the instance of the type we are extending, suppose the extension method takes another argument

public static class Extend { public static string RomanNumber(this int number, bool upperCase) { // do complex logic return romanString; } }
 

Here is how we validate the arguments.

Reflective Mocks (Community Edition)

We have to implicitly ignore the first argument

// first arg is instance, second must be false Mock extentionMethodMock = MockManager.Mock(typeof(Extend)); extentionMethodMock.ExpectAndReturn("RomanNumber","MCMLIX"). Args(Check.IsAny(),false);

Natural Mocks (Professional Edition)

TypeMock automatically handles the first argument

using (RecordExpectations rec = new RecordExpectations()) { // TypeMock knows that this is an extension method and ignores first
// argument automatically
rec.ExpectAndReturn( 2010.RomanNumber(false), "MCMLIX") .CheckArguments(false); }
 
Oct
12
Comments

NCover 2.0

Author Eli Lopian    Category Product     Tags

imagePeter Waldschmidt has announced the release a new commercial version of NCover. NCover is now developed in  a new company called Gnoso. The new NCover is a complete Code Coverage Solution and combines Grant Drake’s NCoverExplorer

To use NCover 2.0 with TypeMock.NET, you will need to install TypeMock version 4.1. This now includes a option to link with NCover 2.0.
Now with Ncover 2.0 and TypeMock you can test and measure your 64 bit code! Both tools support 64 bit architectures and are integrated together.

Remember that all .NET 2.0+ code will run automatically in 64 bit and all .NET 1.1 code will always run in 32 bit mode.
To run .NET 2.0+ code in 32 bit, you must set the 32 bit flag of the executable.

Here is how:

corflags.exe /32BIT+ <path-to-executable>

Jamie has already created a TestDriven.Net version (2.9) that combines NCover 2.0 and TypeMock when running your tests.

Oct
12
Comments

TypeMock 4.1 Released

Author Eli Lopian    Category Product     Tags

Syndicated from the TypeMock Announcement Forum.

We have released TypeMock 4.1.

A few of the new features included in this release are:
Arrow Support of .NET 3.5 syntax changes

    Mocking automatic properties.
      Mocking Anonymous Types.
      Mocking Lambda Expressions.
      Verifying New Initialziers.
      Mocking Extension Methods.
      Mocking LINQ statements.

    Arrow Integration API for tools developers
    New API was released to ease integrating TypeMock with other developer tools.

    Arrow Tracer Enhancement (Professional Editions)
    The tracer tool has been enhanced with the ability to pause and resume trace gathering, the ability to resize its different panes, and the marking of the start and end of each test.

    Arrow NCover 2.0 Support (Professional Editions)
    The new release of NCover tool (2.0.1) is now supported and can be linked to run with TypeMock
    Arrow Support of Visual Studio Orcas Beta 2
    TypeMock.NET can be run on Visual Studio Orcas Beta 2.
    Arrow Many fixes

    More information can be found in the Release Notes