Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from MSTest to NUnit #48

Merged
merged 1 commit into from
Aug 18, 2016

Conversation

janbernloehr
Copy link
Contributor

Migration to NUnit 3.4.1 to allow cross platform testing. Visual Studio Integration for NUnit can be downloaded here.

Notable changes are

  • Replaced Microsoft.VisualStudio.TestTools.UnitTesting with NUnit.Framework
  • Using AppDomain.CurrentDomain.BaseDirectory instead of Assembly.GetExecutingAssembly().Location to the determine the location of .docx files and other resources. This method is invariant under the test runner in use -- see TestHelper.
  • Using Path.Combine("a", "b") to build paths of the form "a\b" or "a/b" depending on the platform.
  • Resources are set to "Copy if newer" to include them during build.

…e downloaded here: https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d

Using AppDomain.CurrentDomain.BaseDirectory instead of Assembly.GetExecutingAssembly().Location to the determine the location of .docx files and other resources. This method is invariant under the test runner in use.
Resources are set to "Copy if newer" to include them during build.
@PrzemyslawKlys PrzemyslawKlys merged commit 4778cd4 into xceedsoftware:master Aug 18, 2016
@PrzemyslawKlys
Copy link
Contributor

I've commited this but 9 tests failed ;)

@PrzemyslawKlys
Copy link
Contributor

Test Name: GenerateHeadingTestDocument
Test FullName: UnitTests.DocXUnitTests.GenerateHeadingTestDocument
Test Source: C:\Projects-GitHub\DocX\UnitTests\DocXUnitTests.cs : line 2175
Test Outcome: Failed
Test Duration: 0:00:00,123

Result StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at Novacode.DocX.Save() in C:\Projects-GitHub\DocX\DocX\DocX.cs:line 3644
at UnitTests.DocXUnitTests.GenerateHeadingTestDocument() in C:\Projects-GitHub\DocX\UnitTests\DocXUnitTests.cs:line 2187
Result Message: System.UnauthorizedAccessException : Access to the path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Document Header Test.docx' is denied.

@PrzemyslawKlys
Copy link
Contributor

I guess replacing earlier version of _directoryWithFiles with new method didn't work as expected :-)

@janbernloehr
Copy link
Contributor Author

I see. Does this happen with the NUnit 3 Test Adapter? Tests on my local VS install and AppVeyor all pass.

@janbernloehr
Copy link
Contributor Author

Are you using NUnit 2 by any chance instead of NUnit 3?

@PrzemyslawKlys
Copy link
Contributor

No. I've went to the link you mentioned in your post, run it in Visual Studio. It installed. Then I've tried running tests, it said it needs to get something from Nuget, I assume it did. And finally it gave error on 9 tests. I guess this is because the path to files is wrong as for some reason the "binary" executing the tests isn't in the same folder as the documents.

@PrzemyslawKlys
Copy link
Contributor

PrzemyslawKlys commented Aug 18, 2016

@using (DocX document = DocX.Create(@"Document Header Test.docx"))

on the other hand it's probably error because it can't create that document in the IDE directory... so this needs to be path outside of Visual Studio folder.. in other words .. all DocX.Create() fail because it tries to make those in "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE" - i don't see _directoryWithFiles being used there so most likely not a problem.

@janbernloehr
Copy link
Contributor Author

Definetly seems to be a path issue.
I will look into it as soon as I get home.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants