c# - Unit testing a .NET Standard 1.6 library -


i having trouble finding date documentation on how unit test .net standard 1.6 class library (which can referenced .net core project).

here project.json looks library:

{   "supports": {},   "dependencies": {     "microsoft.netcore.portable.compatibility": "1.0.1",     "netstandard.library": "1.6.0",     "portable.bouncycastle": "1.8.1.2"   },   "frameworks": {     "netstandard1.6": {}   } } 

now left on task able create sort of project can unit testing. goal use xunit since seems .net core team pushing.

i went ahead , created .net portable library project has project.json looks this:

{   "supports": {},   "dependencies": {     "microsoft.netcore.portable.compatibility": "1.0.1",     "netstandard.library": "1.6.0",     "xunit": "2.2.0-beta4-build3444",     "xunit.runner.visualstudio": "2.1.0"   },   "frameworks": {     "netstandard1.6": {      }   } } 

my test class within project looks this:

using usb.enterpriseautomation.security.dotnetcore; using xunit;  namespace security.dotnetcore.test {     public class aesencryptionhelpertests     {         [fact]         public void aesencryptdecrypt()         {             var input = "hello world!";             var encrypted = aesencryptionhelper.aesencrypt(input);             var decrypted = aesencryptionhelper.aesdecrypt(encrypted);              assert.equal(input, decrypted);         }     } } 

when go ahead , build project, test explorer not seeing of tests.

how go creating unit test that's able test library?

i have working project using xunit 2.1.0 , dotnet-test-xunit 2.2.0-preview2-build1029.

this project.json unit test project:

{   "dependencies": {     "dotnet-test-xunit": "2.2.0-preview2-build1029",     "microsoft.netcore.app": {       "type": "platform",       "version": "1.0.0"     },     "myproject.library": {       "target": "project",     },     "xunit": "2.1.0"   },   "description": "unit tests",   "frameworks": {     "netcoreapp1.0": {       "imports": "dotnet"     }   },   "testrunner": "xunit" } 

this works both on command line (via dotnet test) , in visual studio 2015 test explorer.

i think dotnet-test-xunit being deprecated, i'm not sure. of above change after project.json goes away, works today.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -