I'm trying run tests from nunitlite-runner.exe but i got Error message
1) Invalid : /myfile.dll
Has no TestFixtures
I have in source code
[TestFixture]
public class MyClassName
{
[Order(1)]
[Test]
public void Case1()
{
//
}
[Order(2)]
[Test]
public void Case2()
{
//
}
}
How can i fix code or run my tests?
I got this problem with nunit3-console.exe. I had, in my enthusiasm to upgrade to the latest and greatest, updated my NUnit project references to the latest version (3.9 at this writing), along with my console exe (3.7). But it seems that the console exe is a build or two behind the core libraries, so you can't reference a later version of NUnit than the version you have of the console exe.
I downgraded my NUnit project reference to 3.7, and that fixed it for me.
Related
I ran into the following error after my .net core project and its dependencies to the latest framework version (version 6+) when I was running any CLI command (such as dotnet ef add for instance):
Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage. TypeMappingSourceDependencies' while attempting to activate 'MySql.EntityFrameworkCore.Storage.Internal. MySQLTypeMappingSource'.
I found this article which helped solved the issue: https://www.svrz.com/unable-to-resolve-service-for-type-microsoft-entityframeworkcore-storage-typemappingsourcedependencies/
Adding this class to the project:
public class MysqlEntityFrameworkDesignTimeServices : IDesignTimeServices
{
public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
{
serviceCollection.AddEntityFrameworkMySQL();
new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)
.TryAddCoreServices();
}
}
Adding this class solved for me.
Whenever I run a test file from eclipse it works and display result as:
. 1/1 (100%)
Time: 371 ms, Memory: 8.00MB
OK (1 test, 1 assertion)
But If I run the same test from the Eclipse Oxygen, I get the error:
PHP Fatal error: Declaration of PHPUnitLogger::addFailure(Test $test, AssertionFailedError $e, $time): void must be compatible with PHPUnit\Framework\TestListener::addFailure(PHPUnit\Framework\Test $test, PHPUnit\Framework\AssertionFailedError $e, float $time): void in /tmp/phpunit_printer/PHPUnitLogger.php(415) : eval()'d code on line 1
I downloaded phpunit-7.1.phar, and installed it globally by making it executable and moving it to /usr/local/bin and for Eclipse, I have downloaed in the Download directory and without making it executable I added it into my Eclipse Project as an External Phar but it is not working and giving the above error.
Can someone help me fixing the issue?
By the way, I am a NetBeanse User, but NetBeans is not supporting PHP7.1 that's why moving to Eclipse.
UPDATE
Here is my test file:
<?php
namespace tests\Unit\;
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
public function testSimple() {
$this->assertEquals(1, 1);
}
}
I had exactly the same problem with PHPUnit 7.5.14 and didn't find a solution.
Since I wanted to test my application running with PHP 7.1, I decided to try PHPUnit 6 and it worked at once. So PHPUnit 6.5.14 did the trick for me.
It seems Eclipse is not compatible with PHPUnit 7. My Eclipse Version is 2018-12 (4.10.0) with PDT 6.2. After switching to PHPUnit 6 other problems (that I managed to find workarounds for) were gone too. For example the generated class code overrides TestCase::__construct without calling the parent constructor. It seems to be a problem with PHPUnit 7, not so with 6.
I didn't find a compatibility chart of Eclipse PDT to support my thesis.
When assembly using PostSharp [Log] aspect was decompiled, the decompiled code appeared without new code added to it. Doesn't PostSharp add code corresponding to aspect during precompilation?
PostSharp post-processes the compiler output by reading and disassembling the intermediate assembly, execute the required transformations and validations, and rewriting the final assembly to disk.
PostSharp integrates itself in the build process via PostSharp.targets. NuGet adds the PostSharp.targets import to your project when you install PostSharp nuget package.
Let's consider this method:
[Log]
public void Method() { }
If everything works correctly then the decompiled C# code of this method starts like this (PostSharp 5.0):
public void Method()
{
bool flag = <>z__Program.DefaultCategory.IsEnabled(LogLevel.Debug);
LogMemberInfo logMemberInfo;
If you don't see this code, it may indicate that PostSharp is not correctly installed to your project or it is not correctly configured.
Adding Detailed Logging to your Solution article explains how to correctly configure and add PostSharp to your project.
I'm using NunitLite for my unit testing for a Xamarin project.
Environment:
Windows 8.1 64 bit
Visual Studio 2012
Test project class library referencing .NET 4.5
NunitLite V1.0.0 package from NuGet - contains a build for .NET 4.5
Running tests using Nunit Test Adapter V1.2 from NuGet
With even the simplest test:
[Test]
public void SimpleTest()
{
Assert.That(1 == 1);
}
I'm getting the exception:
System.NullReferenceException was unhandled by user code
HResult=-2147467261 Message=Object reference not set to an instance
of an object. Source=nunitlite StackTrace:
at NUnit.Framework.Assert.IncrementAssertCount()
at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.That(Boolean condition)
at SportLogger.Tests.Unit.Core.when_using_venue_manager.SimpleTest() in
c:\SportLogger\SportLogger.Tests.Unit.Core\CoreTests.cs:line 65 InnerException:
Does anyone have any pointers as to what the problem is?
I solved this by using standard Nunit, not NunitLite. I'm not sure why NunitLite doesn't work in a standard Windows test library.
Bearing in mind that NunitLite is meant to be used (in this context) on the iOS and Android projects, switching to Nunit for the core test project, and NunitLite for the iOS and Android test projects fixed the problem.
For some reason when I open a new solution Resharper always refuses to find unit tests. I spend half an hour struggeling/rebuilding/poking until suddenly Resharper magically finds my unit tests. Once they are found it runs them fine every time.
Test example:
using NUnit.Framework;
namespace NamespaceOfTheCodeToTest.Test
{
[TestFixture]
public class FunctionalityTest
{
[Test]
public void Scenario_Input_Result()
{
}
}
}
I am using RESHARPER->Unit Tests->Run All Tests from Solution
What am I doing wrong here?
It seems the problem was NUnit test adapter was not installed. After installing that visual studio extension all tests where found instantly.
Edit: a better solution is to use "Run Unit Tests" on the test project, folder with test projects or solution.