Test and layout frameworks for Java and .NET

I would like to know your thoughts on test / mock frameworks that are widely used and have a good level of compatibility between Java and .NET. I want to say that I want to learn these tools for use in a .NET project, but I still want to be able to apply this knowledge in Java projects.

  • I know that there are many questions about testing / mocking frameworks for these platforms, especially here in SO, but I have not found a single question comparing these structures regarding its similarity on these two platforms.
+4
source share
8 answers

N / J-series of frameworks ( NUnit / JUnit , NMock / JMock , etc.) are usually parallel ports of each other or based on the same principles of the beginning. This will certainly allow you to transfer at least some of your knowledge between them.

+5
source

Here is what I see from my experience on the Java side of the fence.

Unit Testing Structures

As for unit testing in Java, almost everyone uses JUnit and JUnit 4.0 using annotations, I understand that now it is more like NUnit.

Hiding frames

We used EasyMock in our project for about six months, and we determined that he ate a lot of our time just for simple tasks. In fact, we joked a lot about how EasyMock is not easy.

After attending a lecture on mocking frames, I decided to go with Mockito and never looked back. This allows you to partially mock painlessly - for which EasyMock requires a separate library. In addition, Mockito has much better error messages. When you do something wrong, it will give you detailed errors about how you broke the Mockito contract.

In any case, give both spins, and I think you will agree that Mokito is a clear winner.

+4
source

I would advise you to take a look at Moq for a taunt in .NET. This is conceptually very similar to Mockito on the Java side.

+3
source

We use RhinoMocks and NUnit for our .NET projects. JUnit will be an alternative to Java

+2
source

NMock is far from the best design in the .NET world. It is based on the lines of:

Expect.Once.On(mockView).GetProperty("FromAccount").Will(Return.Value("1234")); 

I highly recommend something more modern like Rhino.Mocks :

 Expect.Call(mockView.FromAccount).Returns("1234"); 
+2
source

First of all, it is important to separate the concepts of testing and ridicule. For unit-testing (to test your tests), the most popular are JUnit (for Java) and NUnit (for .NET). The situation around mocking (or isolating) frameworks is more complicated.

The mocking framework is divided into two camps, which I like to call "regular" and "alternative."

The traditional framework relies mainly on design for testing and dependency injection. The alternative framework relies on things like the profiling API or the Java 5 SE toolkit (java.lang.instrument package) to change the CIL or bytecode in runtime, which makes any dependent womb.

Examples of such alternative networks are: Typemock Isolator (for .NET) and JMockit (for Java) (Typemock is not free unless you use it in an open source project.)

Regarding conventinal mocking frameworks for .NET , the two most popular currently are RhinoMocks and Moq . Both are heavily dependent on the capabilities of C # 3.0, especially lambda syntax, to provide concise characteristics of the behavior and expectations of mock objects.

+2
source

I used EasyMock in some Java projects and I really like it. There seems to be a .NET port , but I haven't used it personally yet.

As for unit tests, I use JUnit 4.x, which has some nice extensions compared to 3.x. I think NUnit provides similar functionality, but also did not use it.

+1
source

We use MbUnit and Rhino.Mocks for testing. I really like it.

The reason we use MbUnit is the Reflector. Perhaps it can be found in NUnit, but I found it in MbUnit first;)

0
source

Source: https://habr.com/ru/post/1285633/


All Articles