Coder Social home page Coder Social logo

igalkakoon / webapplicationfactorycontentroot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dcs3spp/webapplicationfactorycontentroot

0.0 0.0 0.0 234 KB

What is the correct usage for WebApplicationContentRootAttribute?

C# 63.83% CSS 11.04% HTML 18.92% Dockerfile 6.21%

webapplicationfactorycontentroot's Introduction

Overview

This repository has been created to highlight difficulties encountered while trying to figure out how to use WebApplicationFactory and the WebApplicationFactoryContentRootAttribute using the provided documentation.

Please refer to github issues and discussions:

This repository highlights the problems that I am encountering while trying to figure out how to use WebApplicationFactory.

Correct usage of WebApplicationFactoryContentRootAttribute

See GitHub issue and discussion.

When I use ContentRootPath property with an invalid path I cannot get an exception or warning message displayed when running the test assembly. Am I using the attribute correctly? It is as though my usage of the WebApplicationFactoryContentRootAttribute is being ignored, possibly due to incorrect Key property value? Please refer to test project below and try to run dotnet test from within that folder:

  • Tests/FunctionalTests/WebApp.FunctionalTests

I have also tried to use the WebApplicationFactoryContentRootAttribute in conjunction with a WebApplicationFactory<TStartup>, where TStartup is derived form the live Startup class, WebApp.Startup. The factory uses a specific appsettings.json file. I am trying to set the content root to be the base dir for the live Startup class at Src/WebApp. However, I cannot seem to get the WebApplicationFactoryContentRootAttribute attribute to be recognised. Please refer to test project below and try to run dotnet test from within that folder:

  • Tests/FunctionalTests/WebApp.FunctionalTests.DerivedStartup

UseSolutionRelativeContentRoot Works In Local Environment But Fails In Docker Container

See GutHub issue.

I have also tried to use UseSolutionRelativeContentRoot in conjunction with a WebApplicationFactory<TStartup>, where TStartup is derived form a live Startup class, WebApp.Startup. Again, the factory uses a specific appsettings.Local.json file.

This time I use the UseSolutionRelativeContentRoot method to set the content root to my live WebApp.Startup class at Src/WebApp, relative to the folder containing *.sln files. This gives some degree of success.

When the test is run using dotnet test --logger=Console;verbosity=detailed it runs successfully on a local development environment. However, it is failing when I run it in the Docker container, why?

For details on how I am compiling and running the docker container containing the test, please refer to ../../../Docker/README.md

Please refer to test project below and try to run dotnet test from within that folder:

  • Tests/FunctionalTests/WebApp.FunctionalTests.UseSolutionRelativeContentRoot

webapplicationfactorycontentroot's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.