TearDown : JetBrains.Util.Tests.TestLoggerListener+TestWrapperException : Expected: not null But was: null

I'm getting the following exception when attempt to run my first unit test, the unit test is shown first followed by the exception. The test file 'cleanup01.cs' is in the correct directory.

Does anyone know what I'm doing wrong?

Cheers

Ollie

[TestFixture]
    public class ReactiveTests : CodeCleanupTestBase
    {
        [Test]
        public void CleanupTest()
        {
            DoTestFiles("cleanup01.cs");
        }

        protected override string RelativeTestDataPath
        {
            get { return "ReactiveCodeCleanup"; }
        }
    }







TearDown : JetBrains.Util.Tests.TestLoggerListener+TestWrapperException : Expected: not null But was: null

--- EXCEPTION #1/2 [AssertionException]
Message = “
    Expected: not null
    But was:  null


ExceptionPath = Root.InnerException
ClassName = NUnit.Framework.AssertionException
HResult = COR_E_EXCEPTION=80131500
Source = nunit.framework
StackTraceString = “
     at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
     at NUnit.Framework.Assert.IsNotNull(Object anObject)
     at JetBrains.ReSharper.TestFramework.BaseTestWithTextControl`1.OpenTextControl(IProject project) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithTextControl.cs:line 196
     at JetBrains.ReSharper.FeaturesTestFramework.CodeCleanup.CodeCleanupTestBase.DoTest(IProject testProject) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Features\src\CodeCleanup\CodeCleanupTestBase.cs:line 49
     at JetBrains.ReSharper.TestFramework.BaseTestWithSingleProject.<DoTest>b__27() in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSingleProject.cs:line 46
     at JetBrains.DocumentModel.DocumentSettings.ExecuteWithOpenDocumentAfterModification(Action action) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Documents\src\DocumentSettings.cs:line 48
     at JetBrains.ReSharper.TestFramework.BaseTestWithSingleProject.DoTest() in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSingleProject.cs:line 48
     at JetBrains.ReSharper.TestFramework.BaseTestWithTextControl`1.<>n__FabricatedMethod21()
     at JetBrains.ReSharper.TestFramework.BaseTestWithTextControl`1.<DoTest>b__1f(Lifetime lifetime) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithTextControl.cs:line 377
     at JetBrains.DataFlow.Lifetimes.Using(Action`1 F) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Util\src\DataFlow\Lifetime\Lifetimes.cs:line 26
     at JetBrains.ReSharper.TestFramework.BaseTestWithTextControl`1.DoTest() in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithTextControl.cs:line 379
     at JetBrains.ReSharper.TestFramework.BaseTestWithSolution.<>c__DisplayClass14.<DoTestSolution>b__13(Lifetime lt, ISolution solution) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSolution.cs:line 459
     at JetBrains.ReSharper.TestFramework.BaseTestWithSolution.<>c__DisplayClass11.<DoTestSolution>b__8(Lifetime lifetime) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSolution.cs:line 430
     at JetBrains.DataFlow.Lifetimes.Using(Action`1 F) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Util\src\DataFlow\Lifetime\Lifetimes.cs:line 26
     at JetBrains.ReSharper.TestFramework.BaseTestWithSolution.<>c__DisplayClass11.<DoTestSolution>b__7() in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSolution.cs:line 430
     at JetBrains.Application.IShellLocksEx.ExecuteWithReadLock(IShellLocks thіs, Action F) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Shell\src\Threading\ShellLocks.cs:line 989
     at JetBrains.TestShell.Infra.BaseTest.<>c__DisplayClass22.<RunGuarded>b__21() in c:\BuildAgent\work\1d5606e7e667bf54\Platform\test\src\Framework\_Core\src\BaseTest.cs:line 325
     at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Util\src\Concurrency\ReentrancyGuard.cs:line 266


--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = “
    Expected: not null
    But was:  null


ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
     at JetBrains.Util.Logger.LogException(Exception ex) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Util\src\Logger\Logger.cs:line 623
     at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\src\Util\src\Concurrency\ReentrancyGuard.cs:line 266
     at JetBrains.TestShell.Infra.BaseTest.RunGuarded(Action action) in c:\BuildAgent\work\1d5606e7e667bf54\Platform\test\src\Framework\_Core\src\BaseTest.cs:line 328
     at JetBrains.ReSharper.TestFramework.BaseTestWithSolution.DoTestSolution(TestSolutionConfiguration testSolutionConfiguration, Action`2 test) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSolution.cs:line 431
     at JetBrains.ReSharper.TestFramework.BaseTestWithSolution.DoTestSolution(TestSolutionConfiguration testSolutionConfiguration, Action test) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSolution.cs:line 460
     at JetBrains.ReSharper.TestFramework.BaseTestWithSolution.DoTestSolution(TestSolutionConfiguration testSolutionConfiguration, Func`2 wrapper) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSolution.cs:line 354
     at JetBrains.ReSharper.TestFramework.BaseTestWithSingleProject.DoTestSolution(String[] fileSet) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithSingleProject.cs:line 102
     at JetBrains.ReSharper.TestFramework.BaseTestWithTextControl`1.DoTestSolution(NamedPositionsProcessor positionsProcessor) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithTextControl.cs:line 314
     at JetBrains.ReSharper.TestFramework.BaseTestWithTextControl`1.DoTestFiles(String[] testFiles) in c:\BuildAgent\work\1d5606e7e667bf54\Psi.Features\test\src\Framework\Services\BaseTestWithTextControl.cs:line 306
     at Resharper._7._1.ReactivePlugin.Tests.ReactiveTests.CleanupTest() in d:\Work\Visual Studio 2012\Projects\Resharper.7.1.ReactivePlugin\Resharper.7.1.ReactivePlugin\Resharper.7.1.ReactivePlugin.Tests\ReactiveTests.cs:line 12
     at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
     at NUnit.Core.Reflect.InvokeMethod(MethodInfo method, Object fixture, Object[] args)
     at NUnit.Core.TestMethod.RunTestMethod(TestResult testResult)
     at NUnit.Core.TestMethod.RunTestCase(TestResult testResult)
     at NUnit.Core.TestMethod.RunTest()
     at NUnit.Core.NUnitTestMethod.RunTest()
     at NUnit.Core.TestMethod.RunRepeatedTest()
     at NUnit.Core.TestMethod.RunTestInContext()
     at NUnit.Core.TestMethod.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestFixture.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.SetUpFixture.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunAllTests(TestResult suiteResult, EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuite(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.RunSuiteInContext(EventListener listener, ITestFilter filter)
     at NUnit.Core.TestSuite.Run(EventListener listener, ITestFilter filter)
     at NUnit.Core.SimpleTestRunner.Run(EventListener listener, ITestFilter filter, Boolean tracing, LoggingThreshold logLevel)
     at JetBrains.ReSharper.UnitTestRunner.nUnit.NUnitTestRunner.Run(EventListener listener, ITestFilter filter)
     at JetBrains.ReSharper.UnitTestRunner.nUnit.NUnitTaskRunner.ExecuteRecursive(TaskExecutionNode node)
     at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.Execute(TaskExecutionNode node)
     at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.DoExecuteNodes(IEnumerable`1 nodes)
     at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.<>c__DisplayClass2.<ExecuteNodes>b__1()
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ThreadHelper.ThreadStart()

1 comment
Comment actions Permalink
Annoyingly, this is one of those errors you can diagnose by looking at the underlying code. First, copy the stack trace to the clipboard. Then open dotPeek, add all of the ReSharper SD K binaries and then go to Tools -> Browse Stack Trace. From here you can navigate to the OpenTextControl method and see that the only call to NUnit's Assert.IsNotNull is checking that the caretPosition variable is not null. You can trace the caretPosition back to the GetCaretPosition() method, which in turn leads to CaretPositionProcessor's CaretPosition or SelectionStart. Taking a look through the rest of this class, we can see ProcessPositionNames, and see that it sets CaretPosition in response to "caret", and SelectionStart in response to "selstart". What this is saying is that your gold .cs file needs to include either {caret} or {selstart} (and therefore also {selend}). This essentially sets up a mock text control, with the position of the caret (the text cursor) or the start and end of the selection. So you just need to edit your .gold file to include {caret} somewhere. The position is important for certain tests such as context actions, which are only visible when the caret is in a certain position.
0

Please sign in to leave a comment.