nunit / docs Goto Github PK
View Code? Open in Web Editor NEWDocumentation for all active NUnit projects
Home Page: https://docs.nunit.org
License: MIT License
Documentation for all active NUnit projects
Home Page: https://docs.nunit.org
License: MIT License
The documentation doesn't accurately say where the randomizer object is exposed:
The Randomizer object exposed by
TestContext.Random
The object is actually found at TestContext.CurrentContext.Random
.
I was just coming along to fill in the empty links that were previously on the docs homepage, but seen they've been removed.
As the samples already exist, I think they may get more visibility if they're linked from the docs. Previously they were on the main home page. Is this an appropriate place for them? We could either have each repo linked in the sidebar, or a link to a code samples homepage?
Regardless of what people think about the above, I think they should definitely (also) feature in the sidebar of the NUnit Documentation section, as various links to this bypass the wiki homepage. I'd think a link from this section would be most visible to the new user's who would find samples helpful.
Thoughts?
I'm very unsure of the actual behavior of the CollectionContainsConstraint after reading the documentation.
The note at the bottom says the following:
For references,
Has.Member
uses object equality to find a member in a collection. To check for an object equal to an item [in?] the collection, use Has.Some.EqualTo(...)`.
I'm not able to say how these two differ. When I first read it, I though that Has.Member
used reference equality, but that is wrong โ this is however clear from Examples of Use.
So how do they differ? And how do you check if the collection contains an object that is reference equal to the provided object?
Readme.md has links to pages whose names have changed and is lacking a link to the developer docs.
I have installed Version 3.0.8.0 of the NUnit3 Test Adapter in Visual Studio 2015 Update 2 and have added NUnit 3.2.0 via NuGet to my Universal Windows Library Project. When the test discovery is running following output is generated:
NUnit Adapter 3.0.8.0 discovering tests is started
Dependent Assembly nunit.framework of .../Tests.dll not found. Can be ignored if not a NUnit project.
NUnit Adapter 3.0.8.0 discovering test is finished
and 0 tests are discovered. I have annotated the test class with [TestFixture] and the method with [Test].
On EmptyConstraint:
Assert.Thst
.DirectoryInfo
.Below is a quick write up of the two missing empty constraints, just adapted from the EmptyDirectoryConstraint page.
https://gist.github.com/ChrisMaddock/8e3fb6fa1bdf1a7a722e
And lastly, spotted while stealing examples, on CollectionOrderedConstraint:
>
and <
in the Modifiers section,Assert.That( sarray2, Is.Ordered.By("Length");
Thanks!
Document the purpose and use of the Engine API in a page under technical notes. This can start from the specification page on the Dev wiki, which will have to be updated. Examples should be provided.
On https://github.com/nunit/docs/wiki/CollectionContainsConstraint#modifiers, the Modifiers section contains HTML tags:
...Using(IComparer comparer)
...Using<t>(IComparer<T> comparer)
...Using<t>(Comparison<T> comparer)
Should probably be
...Using(IComparer comparer)
...Using<T>(IComparer<T> comparer)
...Using<T>(Comparison<T> comparer)
Notice also that the type parameter is currently written in lower case.
this test case not never called and gives error.
// Test with an expected result
[Test(ExpectedResult = 4)]
public int TestAdd()
{
return 2 + 2;
}
Message:
...
Test Outcome: Failed
Test Duration: 0:00:00.0000001
Result Message: Test method has non-void return type, but no result is expected
There's some new naming collisions in the wiki. I stumbled across it going to the Console-Runner page in NUnit, which seems to be clashing with a dev wiki page - not sure if there are others as well. Not set up to look at it properly right now, so adding the issue so it's not forgotten!
The PropertyAttribute page at https://github.com/nunit/docs/wiki/Property-Attribute says that properties of tests are not used by NUnit. That's not really true. Some standard properties like "Order" are used by NUnit. We should document that usage so users don't accidentally create properties that have an unexpected affect on how the test runs.
Users need to understand the limitations of --domain=None so they will only use it if absolutely needed. See nunit/nunit#1409 for example. We should document this information somewhere.
Hello! I've got a test fixture like this
[TestFixture]
public class TestClass
{
[Test]
[Explicit]
public void Explicit_Should_NeverRun() => Assert.Fail();
[Test]
[Category1]
public void Category1() => Assert.Pass();
[Test]
[Category2]
public void Category2() => Assert.Pass();
[Test]
public void BasicTest() => Assert.Pass();
}
public class Category1Attribute : CategoryAttribute
{
}
public class Category2Attribute : CategoryAttribute
{
}
The problem is that, when I run .\nunit3-console.exe .\NUnitAttributeTests.dll --where="cat != Category1 && cat != Category2"
, it executes explicit test, too (this page states that it shouldn't).
Is there a way to exclude explicit tests explicitly ๐ in such a situation?
I need to specify the results file location while running the NUnit test from command prompt.
Which command parameter can I specify for the same?
NUnit is still compiled for old .net frameworks, which is great. I maintain a shared library used in old VS2008 net35 projects (phone 6.5, ugh) and also used in latest VS2015 net46 projects. Today I tried to transition from NUnit 2.6.4 to 3.2.0 running into current directory issues for resource files (content, copy if newer). Using the TestContext.CurrentContext.TestDirectory
works fine for recent net46 projects using NuGet to pull NUnit.
However, referencing packages\NUnit.3.2.0\lib\net20\nunit.framework.dll
from VS2008, net35 the call to TestContext.CurrentContext.TestDirectory
throws a NullReferenceException
, eventually because the working directory is null
.
I have implemented ITestAction interface and overrided before&after test methods, but I cant catch the exception thrown at the end of every test.
I would be interested to know if there is a specific reason why it is currently not possible to access the arguments passed to a parameterized test from a test action.
In the debugger I can see this information as part of an internal Arguments
property of the ITest
implementation (TestMethod
in this situation).
Access to a test's arguments collection would be extremely helpful for designing test actions that provide a somewhat dynamic behavior (based an certain argument values).
I can't seem to get all of my tests to run in VS 2015. All the tests are displayed in Test Explorer and I can run any test individually just fine, but it won't run them all. Highlighting them all and running selected doesn't work any better.
As an example, I've currently got 79 unit tests. I just clicked "Run All" in Test Explorer and 19 tests passed, the other 60 are in "Not Run Tests". I select the first 6 in "not run" and run selected, 1 is processed. I then run selected again (the ones not run are still highlighted) and 4 more are processed. The numbers are very inconsistent and doesn't seem to be hanging up on any particular unit test.
One odd thing that I've noticed a few times is that it seems that some run (the icon turns green) but then, once the tests are completed, the tests switch back to "not run".
Very odd behavior. I would run the nunit gui, but it doesn't seem to be part of the installation any more (though I can't seem to find any documentation on this changing).
Add a page, linked from Engine Extensibility, telling about this extension point.
This is pretty well described in one of our specifications. That page needs to be copied somewhere in the docs and brought up to date. We should link to it from TestCase and TestCaseData.
Document how to install extension packages
We need one or more pages that list all the elements and point to the constraint they implement.
Hi,
I'm using TestCaseData class to run a test with several iterations.
Up until NUnit 3, I was able to set several categories for each iteration by - data.Categories.Add(cat).
In NUnit 3 it was changed to - data.SetCategory(cat) - that can set only one category for each iteration.
How can get the required functionality in NUnit 3?
Thank you!
Should be a new page
The page at https://github.com/nunit/docs/wiki/Attributes has a table of attributes. The second column needs to be filled in with a brief description. This can be kept short since the page itself is only a click away.
When running say 1 test via
"c:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" --x86 --verbose --labels=All --timeout=300000 --trace=Verbose Genesyslab.Lync.Test.dll --testlist=CustomTestList.txt --result=C:\Jenkins\workspace\WPLync-Regression-Runner\nunit-result-QA180.xml;format=nunit2
If within the test I have console.writeln(). It does not get written out until the test is run to the end.
Is there an option which will output to console.
If have found that if I use the NUNIT 3 plugin adapter, then I don't get console output at all.
Hello,
My team is using NUnit as our unit-testing framework.
We are using Visual Studio Team Services as our Build and CI server.
In this set up we do not control the machine where the build agents are running.
Without the NUnit 3.0 Test Adapter Nuget Package we cannot run our NUnit test as part of our build as we cannot install the visual studio runner extension on the build agent machine.
We would need a nuget package like it is possible with xUnit -> http://xunit.github.io/docs/getting-test-results-in-vsts.html
Why was the NUnit 3 Test Adapter pulled from Nuget? as seen on the page https://github.com/nunit/docs/wiki/Adapter-Installation ->
(As 12/11/2015, "NUnit 3.0 Test Adapter" is not found in Nuget. It is only available as Extension)
Is there any roadmap when it will be available again?
Any other workaround you would know off?
Thanks
The See also link at the bottom of the Assert.Contains page doesn't work. I can't even find the page that it should point to.
Page at https://github.com/nunit/docs/wiki/XML-Formats needs significant updates. In particular, the section on progress events has almost no information.
is the parallelscope.self started working? Because, I don't see the methods inside a fixture is not running parallel. But, all fixtures are running parallel if I use parallelscope.fixtures
As per the following SO question comment I suggest to add the FAQ page where the most asked question would be listed with answers. I think adding a page with the name like "Things You Must Not Assume" would be rather specialized while having a general FAQ page might be useful for different questions not just for those assumptions related.
There is a small typo when using Is.TypeOf.
The documentation uses Is.Typeof (small o)
Not sure where this goes... wherever Is.Negative and Is.Positive are documented.
https://github.com/nunit/docs/wiki/Installation refers to the alpha packages and such and needs a general update.
If you google "nunit ignore attribute" the top results are all for earlier versions.
On this page, both the Test
and TestCaseSource
attributes are specified. I normally only specify TestCaseSource
on it's own, as it's done on this page.
Is one way considered 'better practice' than the other, or is the test attribute simply redundant in the first case? Or was it historically required? I checked it out locally and it doesn't appear to make any difference to what's actually run - but seeing the additional attribute at first did make me want to check my tests were actually running!
This page needs update: https://github.com/nunit/docs/wiki/Custom-Attributes
The wiki (https://github.com/nunit/docs/wiki/TestCaseData) reads:
Although any object implementing ITestCaseData may be used to provide extended test case information [...]
However, when I create a custom object implementing the ITestCaseData
interface, I get:
An exception was thrown while loading the test.
System.InvalidCastException: Unable to cast object of type 'CustomTestCaseData' to type 'NUnit.Framework.Internal.TestCaseParameters'.
at NUnit.Framework.TestCaseSourceAttribute.<BuildFrom>d__21.MoveNext()
at NUnit.Framework.Internal.Builders.DefaultTestCaseBuilder.BuildFrom(IMethodInfo method, Test parentSuite)
at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.AddTestCasesToFixture(TestFixture fixture)
at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.BuildFrom(ITypeInfo typeInfo)
at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.BuildFrom(ITypeInfo typeInfo)
A number of links appear to have broken with the transfer to the new wiki. Various side-bar links in NUnit Docs now point to Adapter Docs.
I have never used a GitHub wiki, but it appears that filenames need be unique? (Ref StackOverflow) In which case prefixing each file with the project name might be necessary? Would be happy to sort that if it's necessary.
Additionally, all images in the NUnit Docs section are missing - I presume they DO observe directory structure, but need to be relative to root.
The documents for TestFixtureSource
references ITestCaseData
when it should reference ITestFixtureData
. If you do however use ITestCaseData
an No suitable constructor was found
exception will be thrown.
I've included a diff:
diff --git a/nunit/TestFixtureSource-Attribute.md b/nunit/TestFixtureSource-Attribute.md
index 0a7c47b..f9d3449 100644
--- a/nunit/TestFixtureSource-Attribute.md
+++ b/nunit/TestFixtureSource-Attribute.md
@@ -110,9 +110,9 @@ TestCaseSourceAttribute supports one named parameter:
In constructing tests, NUnit uses each item returned by
the enumerator as follows:
-1. If it is an object implementing `NUnit.Framework.ITestCaseData`,
+1. If it is an object implementing `NUnit.Framework.Interfaces.ITestFixtureData`,
its properties are used to provide the test case. NUnit provides
- the [[TestCaseData]] type for this purpose.
+ the [[TestFixtureData]] type for this purpose.
3. If it is an <b>object[]</b>, its members are used to provide
the arguments for the method. This is the approach taken in
It seems that users tend to thing of the adapter as a single thing, even though we have two different extension packages. There's enough similarity in the docs that we may be able to combine them.
This issue is basically the statement of an idea. We should evaluate it generally and then, if we like it, see if we can make it work.
The following is a summary of pages in the two sets of docs and what they contain.
NUnit 3 Adapter | NUnit (2) Adapter | Content |
---|---|---|
Home | NA | Overall documentation Home page |
NA | General Developer Wiki | Dev Wiki Home page |
NUnit VS Adapter | Home | Adapter Home page |
Installation | VS Adapter Introduction | How to Install |
Usage | VS Adapter Introduction | How to use |
Resources | VS Adapter Introduction | More info |
Known Problems | VS Adapter Introduction | Known problems |
NA | VS Adapter Roadmap | Planned releases |
Tips and Tricks | Tips And Tricks | Tips and tricks |
Release Notes | NA | Release Notes |
License | NA | License |
Packaging | How to build and package a release | How to package |
NA | Usage of Labels | Special label for adapter |
Hi,
it would be nice to have multiple asserts support, as described here:
https://github.com/nunit/dev/wiki/Multiple-Asserts
Background:
Having that supported, it would be much easier to convert existing NUnit 2.6 tests using [TestCaseSource](that rely on the fact that the source does not need to be static) into NUnit 3 tests (where the source must be static) with getting almost similar behavior.
BR,
Ralf
How to use setculture/setuiculture to change the chrome/firefox's browser locale or language via selenium and nunit ??
I'm working on migrating from Nunit 2.6.2 to 3.x for our codebase. While testing the new command line arguments for nunit3-console.exe I found it difficult to resolve the path to the nunit.framework.dll 2.6.2 files that are stored in our code repository (rather than installed via MSI or nuget etc).
I was trying to determine how the .\addins\nunit.v2.driver.dll interacted with a particular edition of nunit 2.x. Do I need to
Console Exception
`System.IO.FileLoadException: Could not load file or assembly 'nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77'
Server stack trace:
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilte
rType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecorate
dTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Engine.Drivers.NUnit2FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
at NUnit.Engine.Runners.AbstractTestRunner.Load()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [1]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Engine.ITestEngineRunner.Load()
at NUnit.Engine.Runners.ProcessRunner.LoadPackage()
at NUnit.Engine.Runners.AbstractTestRunner.Load()
at NUnit.Engine.Runners.AggregatingTestRunner.LoadPackage()
at NUnit.Engine.Runners.AbstractTestRunner.Load()
at NUnit.Engine.Runners.MasterTestRunner.LoadPackage()
at NUnit.Engine.Runners.AbstractTestRunner.EnsurePackageIsLoaded()
at NUnit.Engine.Runners.MasterTestRunner.NUnit.Engine.ITestRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter)
at NUnit.ConsoleRunner.Program.Main(String[] args)`
The Property Attribute page currently states that property's can't be used to filter tests and is strictly for display purposes. This is no longer true.
Looking at the Breaking changes list again reminded me of this issue. Is it right that the replacement for Assert.IsNotNullOrEmpty should be Is.Not.Null.Or.Not.Empty? (With the extra 'Not')
The wiki attributes list lists SetUp
and SetUpFixture
attributes as Setup
and SetupFixture
- the u being lowercase. It's actually uppercase in the code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.