Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Use of classes that derive from UserControl.
Sergo
#1 Posted : Monday, April 7, 2014 7:45:03 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/7/2014(UTC)
Posts: 2
Location: Germany

Hi Remco,
I have a problem with NCruch at the classes that derive from UserControl. Using these classes in a project, the icons are not updated and/or the tests are not done.
During my research, I was able to observe a random Exception "System.TypeLoadException: Der Typ "System.Security.SecurityCritical" in der Assembly "mscorlib, Version=4.0.0.0". (in the "Processing Queue Window"). This has given me an idea. Derives a test class from a UserControl, it leads to compiler errors within the NCrunch. The same exception happens. In a test project I have compiled most of my results.

  Important: The error only happen on the Win8.1 computer. The same code runs on Windows 7 without any problems.

Try this code:

Code:
 namespace ClassLibrary1
{

    [TestFixture]
    public class TestClass//: UserControl //Comment out this to get build Problems.
    {

        [Test]
        public void ShouldNotBeNull()
        {
            Assert.True(true);
            //Assert.Fail();
        }
    }

    //public class CommentedMeOutToGetIconUpdateProblem : UserControl
    //{
    //}
}
Remco
#2 Posted : Monday, April 7, 2014 9:21:35 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Sergo,

Thanks for sharing this problem.

The main issue here is that with the test class descending from a UserControl, the code within the UserControl class (probably the constructor) is being executed during test discovery. I'm not sure what exactly happens inside this code, but it probably would vary depending on your platform.

You may be able to work around this problem by setting the 'Framework utilisation type for NUnit' solution-level configuration setting to 'StaticAnalysis'. This will turn off the dynamic test discovery step, causing NCrunch to statically detect the tests instead. It's quite probable that you'll then receive a similar error downstream when NCrunch later constructs the fixture in order to execute its tests.

NCrunch was never designed to work with tests that descend from a complex type such as UserControl. Tests are expected to be simple classes containing code that you are able to easily change and understand. I'm afraid that a technical fix for this issue from the side of NCrunch isn't possible to provide. If the Framework utilisation type setting doesn't allow the test to execute, you'll need to redesign the fixture.

You may also want to have a look at the troubleshooting section under 'System.Security.VerificationException: Operation could destabilize the runtime'. This category of failure is similar to the error you're experiencing .. it's possible that the solutions suggested may be applicable in your case.
Sergo
#3 Posted : Monday, April 7, 2014 11:44:47 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/7/2014(UTC)
Posts: 2
Location: Germany

Hi Remco,
I think I have explained my problem not good enough!

The problem is that as soon as my project contains the class TestUserControl, the NCrunch runner icons are not updated correctly. Instead, they freeze to show the test in running state. Of course, the field "status" also says "running ...".
Please note that the pure existence of the TestUserControl corrupts the NCrunch run, meaning that the class must not even be used to reproduce the error.

Code:

    [TestFixture]
    [RequiresSTA]
    public class TestClass
    {
        [Test]
        public void ShouldNotBeNull()
        {
            //you cann use this code or not. The Icons are stil in State "Running".
            var testObject = new TestUserControl();
            Assert.NotNull(testObject);           
        }
    }

    public class TestUserControl : UserControl
    {
    }



The descending a Test class from a UserControl is still a result of my research and should be just a Hint for you. This Hint has provided only for the confusion.


The change of property of "UseDynamicAnalysis" to "Static Analysis" solved the problem with the Build Errors. My primary problem still persists for.

I tried the usage of the security attribute as you suggested but that did not help.




Remco
#4 Posted : Monday, April 7, 2014 9:52:14 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Sergo,

Thanks for clarifying. In that case, I think this problem may be a runtime assembly reference resolution issue.

Is there any chance you could provide me with a test project that can surface the problem? I can probably provide you with a prompt solution if you're able to submit some failing sample code via the contact form.
Remco
#5 Posted : Friday, April 11, 2014 11:48:22 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,986

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
For anyone interested, Sergei and I troubleshooted this issue and discovered it was caused by a compatibility problem of some kind with Typemock Isolator. The problem seems to be environment specific and in this case seems only to affect the NUnit test framework.

If you experience this problem, please make sure you are running the latest version of TypeMock Isolator.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.040 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download