Is csUnit dead? If so, what are the living alternatives? - unit-testing

I'm trying to find out how to get csUnit and VS2010/.NET 4 to play nice together. There's no mention of .NET 4 in the csUnit FAQ, which also seems very much out of date. I checked out the Yahoo user group, but can't find any user posts past March 2008 there.
Am I correct in assuming that csUnit is dead? In that case, what test framework have the users moved on to?

In addition to Matthew Vines answer (NUnit and MbUnit), I think xUnit.Net is the 3rd active open source UnitTesting solution.
Consider Moq, Rhino.Mocks and FakeItEasy as active Open Source Mocking frameworks.

I would think that nUnit and MbUnit would be the big ones right now.
But here is a reasonably extensive list of options:
http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#.NET_programming_languages

Related

TDD with Sitecore 7 and TFS 2012 CI

So, testing with Sitecore. It's a special topic and I've found allot of reading material regarding it already. (Sitecore Development Chapter 8, Alistair Deneys blog, NextDigital blog, iStern blog,...) but in most of these cases they're going with NUnit and custom test runners etc... The most useful (to me in my context) this far was the iStern blog for mocking out Sitecore using Microsoft Fakes. But is this really the way to go?
I'm surprised that with Hedgehog TDS system to integrate so deeply with TFS and be able to do CI in Sitecore development that there isn't more on how to utilize this system for setting up solid testing executed by TFS (yet).
We're gearing up for a large new project now that uses Sitecore to handle front-end user interaction where the data being used is 95% behind a WCF service. So this part can be easily tested and TDD developed. It's the last 5% (which sadly includes like the highest business value, being online payments) that resides within Sitecore that needs to be tested. Can we ever have enough intimate knowledge of sitecore to mock it out? I'd be inclined to think not... if so, how then do we run conclusive tests on our TFS CI build against sitecore?
Last but not least I get the feeling that the information currently to be found is getting a bit out of date perhaps (maily seeing the remarks on the NextDigital blog), does Sitecore 7 open new ways to tackle this issue?
For those who'd see this more as a philosophical rather then a technical question: There can only be one answer to this and that is a technical accurate definition of a method of using the Microsoft test framework that is capable of running in the TFS CI environment to test code written for Sitecore.
Is Microsoft Fakes the way to go? In my opinion, no. Microsoft fakes allows you to test code that is not designed to be testable. If you design you solution properly, a standard mocking framework should be sufficient.
Can we ever have enough intimate knowledge of sitecore to mock it out? This is kind of a trick question. Unless a third-party library was specifically designed for it and is something that you would consider a "stable dependency", you shouldn't try to mock it. Instead, wrap it with your own classes and abstractions and mock those.
Take a look at Synthesis and Glass Mapper. They are object-mapping frameworks that allow you to map Sitecore items to interfaces while maintaining page editor support. Glass, in particular has a wrapper around Sitecore.Context that can be mocked. Synthesis is supposed to be pretty testable as well, but I haven't tried it yet.
Using one of those mapping frameworks and a good SOLID design, you should be able to make most of your code testable. Just remember that the classes on the edges of your solution should be simple enough to not require testing.
I was in the exact same situation as you, IvanL, a few weeks ago. I wanted to test some of my business logic running against Sitecore 7 without a mocking framework. I managed to do it, but only in a very specific scenario. Unfortunately, I haven't published my prototype solution or the slides explaining it yet, but I'll explain the basics of what I did.
In Sitecore 7, the move towards querying against the index with the Sitecore.ContentSearch namespace and using LINQ opened up a way for me to very easily unit test with fake index data.
There are some unit test examples out there, as you've seen, that use mocking frameworks. However, the classes they mock are actually quite simple to fake out yourself. If you implement ISearchIndex, you really only need to implement the CreateSearchContext method in order to start returning an IQueryable to work with in your tests.
To implement CreateSearchContext, you will likely need to create a fake provider search context implementation that will do the GetQueryable implementation.
Once you have those two classes set up, you've essentially got your 'index' covered. Add a property onto it where you can set the data collection from the unit test and then make sure the context returns that data collection.
That will let you build up a fake index with whatever data POCOs you want, and then pass that through to your standard provider implementations that are running your business data.
The big thing to remember is that this only works for any code you may be writing that will use the new Sitecore 7 way of using LINQ and the IQueryable implementation. Older style code that is running using the Sitecore.Data.Item API still works the way it used to, and has the same limitations as before.
Update: The prototype I mentioned is now available for download: http://blog.nonlinearcreations.com/2014/02/sitecore-7-developers-quest-successful-unit-testing/

CFWheels Unit Testing?

I have searched Google and abroad and I cannot find anything about CFWheels Unit Testing. Does anyone know if it exists and if so can you point me in the right direction?
Thanks,
Darren
This will more than likely be an "experimental" feature in 1.1 and refined in maintenance releases like 1.1.1 (though the functionality is there supposedly).
Unfortunately, our priorities have been in other areas, and we haven't been able to put unit testing of Wheels apps themselves through its paces and get it documented. I'll be sure to update this page as I get more info.

Alternative to Ria Services

Hi I'm looking for another approach than use Ria Services with silverlight.
We are using Silverlight 4 and .NET 4.0
Have someone make any nice solution with shared assemblies (maybe linked files so domain logic are spread). And maybe any nice framwork to make communicating with the wcf services in a clean way?? It would be really nice if it could support preservereferences :)
I'm looking for links and blogs.
I prefer to not use Ria Services cause its Data Driven mind with need to implemmenting ID's everywhere and lack of support for value objects. I'll also using MVVM so all the logic to undo, notify and so on isn't used.
I would take a look at DevForce by IdeaBlade ( http://www.ideablade.com/ ).
The DevForce product has been around for a number of years and definitely has MVVM support. I looked at it for a project recently and I found the team very helpful. There is an evaluation light edition so you can try before you commit to a purchase.

ABAP Unit Test Classes - Good References

I'm looking for good reference material regarding the use of ABAP Unit Test Classes.
I'm interested in any of the following:
Documentation on the functionality
Best Practises
"How To Guides"
Blogs/Books on people's experience in using test-driven development in a SAP environment, particularly what sort of scenarios leans themselves to test-driven development & how you get around the dependency of SAP on business data.
There is some documentation in sap.com.
Also, there is a German PDF (see here) that may be helpful if you know some German ;-) At least it contains a few email addresses of people that may be able to help. Not sure because the PDF is from a conference in 2003, so the contact info may not be too up to date.
Lastly. there seems to be a German book (on Amazon Germany) .. again not sure if that helps you.
Wondering if you'd checked these links...
https://wiki.sdn.sap.com/wiki/display/ABAP/ABAP+Unit
https://wiki.sdn.sap.com/wiki/display/ABAP/ABAP+Test+and+Analysis+Tools
Thanks.
I recently wrote a blog article on my experiences here: Adopting Test Driven Development using ABAP Unit
There is some documentation in SE24 for class CL_AUNIT_ASSERT. Doing a where-used on the class gives an indication of how it is meant to be used.
There also is a 5 part blog series on SAP SDN
UPDATE: There is now also an excellent course on ABAP Unit on OpenSAP.com. It is called
Writing Testable Code for ABAP
The URL for the course is: https://open.sap.com/courses/wtc1

XNA Unit Testing

So I'm interested in hearing different thoughts about what is the best way to go about unit testing XNA Game/Applications. Astute googlers can probably figure out why I'm asking, but I didn't want to bias the topic :-)
I would that this question is geared more toward the approach of unit testing in game development. I mean, XNA is a framework. Plug in NUnit, and begin writing test cases while you develop.
Here is a post on SO about unit testing a game. It'll give you a little insight into how you need to think while progressing.
XNA BOOK
This book shows how to code in XNA but the entire book is based on NUNIT testing. So while you are coding the projects in the book, he also shows you how to write the scripts for NUNIT to test the XNA code.
VS2008 has a nicely integrated unit testing framework. (I assume you're using using the XNA 3.0 CTP with your Zune.)
The Microsoft testing framework is now available in Visual Studio 2008 Professional and up. If you have this software you already have all the software that you need to start testing your games.
Here are two links that will get you started:
Unit tests Overview - http://msdn.microsoft.com/en-us/library/ms182516.aspx
Creating Unit Tests - http://msdn.microsoft.com/en-us/library/ms182523.aspx
If you only have the Visual Studio 2008 Express than you need to use some other testing framework. NUnit is probably the best one, some people even prefer it to MSTest.
After you have all the software you need you can start adding tests for your code.
Here I've posted some basic techniques about unit testing games that you might find useful.
Have you done unit testing before?
If you haven't I could posbily give you some more hints and resources
You should give Scurvy Test a try. Have not used it my self but it looks promising.
I know this is an old post, but for other people wondering how to best go about testing their XNA Games, there is another option. The built-in testing in Visual Studio is definitely great, but is not well suited for games. Everytime a value is needed, you have to pause the game, and then either hover over the variable, go to quick watch, or add a watch. Then you can see the value of the variable at that frame. To see the value again during another frame, you must pause your game, again. This can be a big hassle. Therefore I have created a debugging terminal to run on top of your game. It allows you to see values of variables, invoke methods, and even watch a variable change in real-time all while you game is running! To find out more, visit: http://www.protohacks.net/xna_debug_terminal/
The project is completely free and open source. If you like it, feel free to tell others using XNA Game Studio about it. Hopes this helps out!