Compact Framework Support

Topics: Developer Forum
Jan 5, 2007 at 11:41 AM
Hi, I am a Mobile Developer and am very interested in a NUnit Test Framework that supports Compact Framework 2.

History - I have tried cross compiling both the CSUnit and the NUnit projects - but they both use features which are not supported by CF.

I have just tried cross compiling your NUnitLite code under CF2 and was surprised that I had a few problems with Change Set: 11989:

Type.EmptyTypes - not supported
Type.GetTypeArray(args) - not supported
ConstructorInfo ctor = GetConstructor( type, argTypes ) - not supported
ctor.Invoke(args) - not supported
Environment.NewLine - not supported (all over the code)

I have put temporary fixes in, but have not yet successfully run a test on a Mobile 5 device - probably hours away.

I would be very interested in developing a Visual Interface (Runner) to NUnitLite that works on Phone / Pocket PC different screen configs etc. I like the way CSUnit looks (reports problems within tree itself). I think its important that a Red - Green tester interface exists.

I presume that CF is still a target? Do you need a Mobile Tester?



Jan 5, 2007 at 3:41 PM
ok, after some testing the biggest problem with CF2 version is in the Reflect.cs class, construct function:

public static object Construct(Type type, params object[] args)
{
Type[] argTypes;

if (args == null)
{
args = new object0;
argTypes = Type.EmptyTypes;
}
else
{
argTypes = Type.GetTypeArray(args);
}

ConstructorInfo ctor = GetConstructor(type, argTypes);
return ctor.Invoke(args);
}

The expressions:
Type.EmptyTypes;
Type.GetTypeArray(args);

are not valid for CF2, I guess I could replace Type.EmptyTypes with new Type0. but what to replace GetTypeArray with is the problem. Type does support GetType, but expects you to tell it what type to get!

Any Solutions?
Jan 8, 2007 at 2:57 PM
OK I have the following solution as suggested by:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=737835&SiteID=1

Change the following code:

public static object Construct(Type type,
params object[] args)
{
Type[] argTypes;

if (args == null)
{
args = new object0;
//Was argTypes = Type.EmptyTypes;
argTypes = new Type0;
}
else
{
//Was argTypes = Type.GetTypeArray(args);
argTypes = new Typeargs.Length;
for (int x = 0; x < args.Length; x++)
{
argTypesx = argsx.GetType();
}

}
ConstructorInfo ctor = GetConstructor(type, argTypes);
return ctor.Invoke(args);
}
Feb 6, 2007 at 8:51 PM
Edited Jul 31, 2007 at 2:09 PM

Hi, I am a Mobile Developer and am very interested in a NUnit Test Framework that supports Compact Framework 2.



I have ported a portion of the nunit core framework down to CF 2. I have a GUI test runner that runs on either the emulator or an actual device. I also created several gui testing utilities for convenience. Things like similating button clicks, keyboard input, etc... We have been successfully using this for a few months now, and it is a huge benefit to be able to do true TDD on the mobile platform. It is very easy to use.

If you are interested in this, I can email you the entire source code with instructions. I've spoken a couple of times with Charlie about integrating what I have with nunitlite, but we have both apparently been very busy.

My email address is alan.NOSPAMPLEASEbaldwin@gmaildotcom.

Regards,
-Alan-
Jul 31, 2007 at 2:10 PM
Edited Jul 31, 2007 at 2:14 PM
Here is our source for MobileUnit at SourceForge:

http://sourceforge.net/projects/mobileunit

It is a lightweight version of nunit with a GUI test runner and some .NET Forms testing convenience classes. You will find a sample test project in the downloads section.
Coordinator
Aug 9, 2007 at 3:04 AM
I haven't been keeping up with the forums here and haven't been updating NUnitLite either since I have focused on the new NUnit releases. However, I'm now getting the code base updated and preparing for a release and I have set up a mailing list, which I think will work better for me in having discussions.

Regarding the problems with .NET CF, I have a build that works on my own machine and I'll be updating the code and putting out an 0.1 release soon. The issues are easy enough to resolve:

  • EmptyTypes is just new Type0 - I added a static Reflect.EmptyTypes to make it easy

  • Environment.NewLine is trickier than you might think. I used another static and initialized it to "\r\n" if PocketPC or WindowsCE is defined. Otherwise, I initialize it to Environment.NewLine. I'm not sure that will work on any compact frameworks on Linux - if there even are any. :-(

  • GetTypeArray() is easy to implement. I put it into Reflect.cs.

  • GetConstructor() - I haven't seen this problem. Maybe it's just a side-effect of the EmtpyTypes problem.

I'd appreciate it if we could move this discussion to the new mailing list on GoogleGroups. You can join it at http://groups.google.com/group/nunitlite

I'll also be announcing there when I update the code - I made a few recent updates but they don't include the stuff above yet.

Charlie