Testing ASP.NET Core 2.1 on .NET











up vote
-1
down vote

favorite












I build ASP.NET 2.1 solution based on .NET Framework 4.7.2 cause of dependencies of older packages that I am integrated with.



My solution looks that



<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>


I started to write down second project with is class based on Framework 4.7.2



I started looking for some test approach that can wired up my server and perform test. I Found that ASP.NET Core 2.1 provides Microsoft.AspNetCore.Mvc.Testing so I configure my test, but when I want to to wired up my app its problem with deps.




Project.deps.json'. This file is required for functional tests to run
properly. There should be a copy of the file on your source project
bin folder. If that is not the case, make sure that the property
PreserveCompilationContext is set to true on your project file. E.g
'true'. For
functional tests to work they need to either run from the build output
folder or the Project.deps.json file from your
application's output directory must be copied to the folder where the
tests are running on. A common cause for this error is having shadow
copying enabled when the tests run.




My question is, if Microsoft.AspNetCore.Mvc.Testing is build upon metadata Microsoft.AspNetCore.App is some another option I can perform test on real WebApi that is a Core project targeting net472?



I putted below my class that call my API



/// <summary>
/// One instance of this will be created per test collection
/// </summary>
public class TestHostFixture : ICollectionFixture<WebApplicationFactory<Startup>>
{
public readonly HttpClient Client;

public TestHostFixture()
{
var factory = new WebApplicationFactory<Startup>();
Client = factory.CreateClient();
}
}









share|improve this question
























  • You cannot use .NET Core packages on a .NET Framework project, check out this question: stackoverflow.com/questions/48539730/…
    – obl
    Nov 8 at 22:32












  • I understand, but I don't see any opportunity to test WebApi. That is what I am looking for.
    – Adrian Botor
    Nov 9 at 18:06










  • Well depending on what kind of testing you want to do, you should be able to find a tool for it. One such tool is Swagger. You could also use xUnit for unit testing.
    – obl
    Nov 9 at 18:40










  • I wanted to perform integration test on running software by test framework Microsoft.AspNetCore.Mvc.Testing. I used to do some test before in other app usin Owin test server. I am pushed to rewrite project to WebApi 2.2 and use Owin and Owin test server to perform some xUnit test. I was pretty sure that if I can target against new Core framework that I could use test features as well.
    – Adrian Botor
    Nov 11 at 20:43

















up vote
-1
down vote

favorite












I build ASP.NET 2.1 solution based on .NET Framework 4.7.2 cause of dependencies of older packages that I am integrated with.



My solution looks that



<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>


I started to write down second project with is class based on Framework 4.7.2



I started looking for some test approach that can wired up my server and perform test. I Found that ASP.NET Core 2.1 provides Microsoft.AspNetCore.Mvc.Testing so I configure my test, but when I want to to wired up my app its problem with deps.




Project.deps.json'. This file is required for functional tests to run
properly. There should be a copy of the file on your source project
bin folder. If that is not the case, make sure that the property
PreserveCompilationContext is set to true on your project file. E.g
'true'. For
functional tests to work they need to either run from the build output
folder or the Project.deps.json file from your
application's output directory must be copied to the folder where the
tests are running on. A common cause for this error is having shadow
copying enabled when the tests run.




My question is, if Microsoft.AspNetCore.Mvc.Testing is build upon metadata Microsoft.AspNetCore.App is some another option I can perform test on real WebApi that is a Core project targeting net472?



I putted below my class that call my API



/// <summary>
/// One instance of this will be created per test collection
/// </summary>
public class TestHostFixture : ICollectionFixture<WebApplicationFactory<Startup>>
{
public readonly HttpClient Client;

public TestHostFixture()
{
var factory = new WebApplicationFactory<Startup>();
Client = factory.CreateClient();
}
}









share|improve this question
























  • You cannot use .NET Core packages on a .NET Framework project, check out this question: stackoverflow.com/questions/48539730/…
    – obl
    Nov 8 at 22:32












  • I understand, but I don't see any opportunity to test WebApi. That is what I am looking for.
    – Adrian Botor
    Nov 9 at 18:06










  • Well depending on what kind of testing you want to do, you should be able to find a tool for it. One such tool is Swagger. You could also use xUnit for unit testing.
    – obl
    Nov 9 at 18:40










  • I wanted to perform integration test on running software by test framework Microsoft.AspNetCore.Mvc.Testing. I used to do some test before in other app usin Owin test server. I am pushed to rewrite project to WebApi 2.2 and use Owin and Owin test server to perform some xUnit test. I was pretty sure that if I can target against new Core framework that I could use test features as well.
    – Adrian Botor
    Nov 11 at 20:43















up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I build ASP.NET 2.1 solution based on .NET Framework 4.7.2 cause of dependencies of older packages that I am integrated with.



My solution looks that



<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>


I started to write down second project with is class based on Framework 4.7.2



I started looking for some test approach that can wired up my server and perform test. I Found that ASP.NET Core 2.1 provides Microsoft.AspNetCore.Mvc.Testing so I configure my test, but when I want to to wired up my app its problem with deps.




Project.deps.json'. This file is required for functional tests to run
properly. There should be a copy of the file on your source project
bin folder. If that is not the case, make sure that the property
PreserveCompilationContext is set to true on your project file. E.g
'true'. For
functional tests to work they need to either run from the build output
folder or the Project.deps.json file from your
application's output directory must be copied to the folder where the
tests are running on. A common cause for this error is having shadow
copying enabled when the tests run.




My question is, if Microsoft.AspNetCore.Mvc.Testing is build upon metadata Microsoft.AspNetCore.App is some another option I can perform test on real WebApi that is a Core project targeting net472?



I putted below my class that call my API



/// <summary>
/// One instance of this will be created per test collection
/// </summary>
public class TestHostFixture : ICollectionFixture<WebApplicationFactory<Startup>>
{
public readonly HttpClient Client;

public TestHostFixture()
{
var factory = new WebApplicationFactory<Startup>();
Client = factory.CreateClient();
}
}









share|improve this question















I build ASP.NET 2.1 solution based on .NET Framework 4.7.2 cause of dependencies of older packages that I am integrated with.



My solution looks that



<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>


I started to write down second project with is class based on Framework 4.7.2



I started looking for some test approach that can wired up my server and perform test. I Found that ASP.NET Core 2.1 provides Microsoft.AspNetCore.Mvc.Testing so I configure my test, but when I want to to wired up my app its problem with deps.




Project.deps.json'. This file is required for functional tests to run
properly. There should be a copy of the file on your source project
bin folder. If that is not the case, make sure that the property
PreserveCompilationContext is set to true on your project file. E.g
'true'. For
functional tests to work they need to either run from the build output
folder or the Project.deps.json file from your
application's output directory must be copied to the folder where the
tests are running on. A common cause for this error is having shadow
copying enabled when the tests run.




My question is, if Microsoft.AspNetCore.Mvc.Testing is build upon metadata Microsoft.AspNetCore.App is some another option I can perform test on real WebApi that is a Core project targeting net472?



I putted below my class that call my API



/// <summary>
/// One instance of this will be created per test collection
/// </summary>
public class TestHostFixture : ICollectionFixture<WebApplicationFactory<Startup>>
{
public readonly HttpClient Client;

public TestHostFixture()
{
var factory = new WebApplicationFactory<Startup>();
Client = factory.CreateClient();
}
}






c# asp.net asp.net-core-2.1 web-api-testing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 19:49

























asked Nov 8 at 18:48









Adrian Botor

298313




298313












  • You cannot use .NET Core packages on a .NET Framework project, check out this question: stackoverflow.com/questions/48539730/…
    – obl
    Nov 8 at 22:32












  • I understand, but I don't see any opportunity to test WebApi. That is what I am looking for.
    – Adrian Botor
    Nov 9 at 18:06










  • Well depending on what kind of testing you want to do, you should be able to find a tool for it. One such tool is Swagger. You could also use xUnit for unit testing.
    – obl
    Nov 9 at 18:40










  • I wanted to perform integration test on running software by test framework Microsoft.AspNetCore.Mvc.Testing. I used to do some test before in other app usin Owin test server. I am pushed to rewrite project to WebApi 2.2 and use Owin and Owin test server to perform some xUnit test. I was pretty sure that if I can target against new Core framework that I could use test features as well.
    – Adrian Botor
    Nov 11 at 20:43




















  • You cannot use .NET Core packages on a .NET Framework project, check out this question: stackoverflow.com/questions/48539730/…
    – obl
    Nov 8 at 22:32












  • I understand, but I don't see any opportunity to test WebApi. That is what I am looking for.
    – Adrian Botor
    Nov 9 at 18:06










  • Well depending on what kind of testing you want to do, you should be able to find a tool for it. One such tool is Swagger. You could also use xUnit for unit testing.
    – obl
    Nov 9 at 18:40










  • I wanted to perform integration test on running software by test framework Microsoft.AspNetCore.Mvc.Testing. I used to do some test before in other app usin Owin test server. I am pushed to rewrite project to WebApi 2.2 and use Owin and Owin test server to perform some xUnit test. I was pretty sure that if I can target against new Core framework that I could use test features as well.
    – Adrian Botor
    Nov 11 at 20:43


















You cannot use .NET Core packages on a .NET Framework project, check out this question: stackoverflow.com/questions/48539730/…
– obl
Nov 8 at 22:32






You cannot use .NET Core packages on a .NET Framework project, check out this question: stackoverflow.com/questions/48539730/…
– obl
Nov 8 at 22:32














I understand, but I don't see any opportunity to test WebApi. That is what I am looking for.
– Adrian Botor
Nov 9 at 18:06




I understand, but I don't see any opportunity to test WebApi. That is what I am looking for.
– Adrian Botor
Nov 9 at 18:06












Well depending on what kind of testing you want to do, you should be able to find a tool for it. One such tool is Swagger. You could also use xUnit for unit testing.
– obl
Nov 9 at 18:40




Well depending on what kind of testing you want to do, you should be able to find a tool for it. One such tool is Swagger. You could also use xUnit for unit testing.
– obl
Nov 9 at 18:40












I wanted to perform integration test on running software by test framework Microsoft.AspNetCore.Mvc.Testing. I used to do some test before in other app usin Owin test server. I am pushed to rewrite project to WebApi 2.2 and use Owin and Owin test server to perform some xUnit test. I was pretty sure that if I can target against new Core framework that I could use test features as well.
– Adrian Botor
Nov 11 at 20:43






I wanted to perform integration test on running software by test framework Microsoft.AspNetCore.Mvc.Testing. I used to do some test before in other app usin Owin test server. I am pushed to rewrite project to WebApi 2.2 and use Owin and Owin test server to perform some xUnit test. I was pretty sure that if I can target against new Core framework that I could use test features as well.
– Adrian Botor
Nov 11 at 20:43



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214283%2ftesting-asp-net-core-2-1-on-net%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214283%2ftesting-asp-net-core-2-1-on-net%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()