Using NUnit to perform integration tests with ASP.NET WebApi controllers

前端 未结 1 736
萌比男神i
萌比男神i 2021-02-08 21:24

I\'m trying to setup a test using NUnit to perform some integration testing of ASP.NET WebApi controllers. I\'ve found a couple articles discussing In-Memory hosting using Htt

1条回答
  •  -上瘾入骨i
    2021-02-08 21:40

    I was seeing this problem also, seemed to go away when I moved my test class into the same assembly as my controller; generally not practical for testing I know.

    After a bit of digging it appears there's a bug that only occurs with self host when the calling code doesn't share the same assembly as the controller as it hasn't managed to load the required assemblies.

    To confirm this is your problem / temporarily workaround add this as the first line of your test: -

    Type myType = typeof(myControllerType);
    

    More info at : http://forums.asp.net/t/1772734.aspx/1

    0 讨论(0)
提交回复
热议问题