Tuesday, February 15, 2005

 

NUnit Dislikes Optional Security Permissions

I recently encountered problems while using NUnit 2.2 on assemblies that specify a security permission set. The problem manifested itself in two different ways for two different assemblies:

  1. NUnit was reporting no test fixtures for assembly A.
  2. SecurityExceptions were being thrown when executing test cases in assembly B for test fixtures derived from classes in assembly A.

Thankfully a Google search led me to another developer who recently had similar troubles. Jason Olson blogged about this issue here.

Jason was having trouble with this permission request:

[assembly: FileIOPermission(SecurityAction.RequestOptional, Write=@"C:\")]

As Jason points out, either commenting out this request altogether or upping the security action to SecurityAction.RequestMinimum solved the problem.

The culprit in my case was:

[assembly: SecurityPermission(SecurityAction.RequestOptional, Flags=SecurityPermissionFlag.UnmanagedCode)].

Sure enough, the same workarounds that Jason discovered solved my problems, too.

These two permission requests seem unrelated to each other and to what NUnit would require to discover unit tests within an assembly. Further, why would NUnit work when these permission requests were either absent or not optional? And therein lies the common thread; they both specify SecurityAction.RequestOptional.

My hypothesis is that NUnit mishandles assemblies that specify optional permission requests. I have notified the NUnit developers of this problem.


Comments:
Bob Bullen of Toronto?
 
Thank you!
[url=http://cltbfnol.com/geqf/amfl.html]My homepage[/url] | [url=http://zppomfwj.com/fjue/eowo.html]Cool site[/url]
 
Well done!
My homepage | Please visit
 
Great work!
http://cltbfnol.com/geqf/amfl.html | http://euxbcxpy.com/agtg/oabj.html
 
Good design!
[url=http://sntrrwbc.com/edna/oruq.html]My homepage[/url] | [url=http://nihprqgd.com/imvq/nqmk.html]Cool site[/url]
 
Thank you!
My homepage | Please visit
 
Well done!
http://sntrrwbc.com/edna/oruq.html | http://uasfmlnc.com/gfhs/gdht.html
 
Post a Comment





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]