# Updating to .NET 8, updating to IHostBuilder, and running Playwright Tests within NUnit headless or headed on any OS

DevFeed: [Updating to .NET 8, updating to IHostBuilder, and running Playwright Tests within NUnit headless or headed on any OS](<https://devfeed.tech/articles/updating-to-net-8-updating-to-ihostbuilder-and-running-playwright-tests-within-nunit-headless-or-headed-on-any-os-21858.md>)

Original publisher: [Read original article](<https://www.hanselman.com/blog/updating-to-net-8-updating-to-ihostbuilder-and-running-playwright-tests-within-nunit-headless-or-headed-on-any-os>)

Author: Scott Hanselman

Published: 2024-03-07T01:12:13Z

Content type: tutorial

Language: en

Sources: [Scott Hanselman](<https://devfeed.tech/sources/scott-hanselman.md>)

Topics: [Playwright](<https://devfeed.tech/topics/playwright.md>), [.NET](<https://devfeed.tech/topics/net.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Browser Automation](<https://devfeed.tech/topics/browser-automation.md>), [Integration testing](<https://devfeed.tech/topics/integration-testing.md>), [ASP.NET](<https://devfeed.tech/topics/aspnet.md>), [Selenium](<https://devfeed.tech/topics/selenium.md>), [GitHub Actions](<https://devfeed.tech/topics/github-actions.md>)

Tags: [asp-net](<https://devfeed.tech/tags/asp-net.md>), [automation-testing](<https://devfeed.tech/tags/automation-testing.md>), [browser](<https://devfeed.tech/tags/browser.md>), [ci-cd](<https://devfeed.tech/tags/ci-cd.md>), [debug](<https://devfeed.tech/tags/debug.md>), [devops](<https://devfeed.tech/tags/devops.md>), [dotnetcore](<https://devfeed.tech/tags/dotnetcore.md>), [integration](<https://devfeed.tech/tags/integration.md>), [linux](<https://devfeed.tech/tags/linux.md>), [net](<https://devfeed.tech/tags/net.md>), [playwright](<https://devfeed.tech/tags/playwright.md>), [selenium](<https://devfeed.tech/tags/selenium.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>), [visual-studio](<https://devfeed.tech/tags/visual-studio.md>), [vs-code](<https://devfeed.tech/tags/vs-code.md>), [web](<https://devfeed.tech/tags/web.md>), [windows](<https://devfeed.tech/tags/windows.md>)

## AI overview

A tutorial on updating a .NET application to .NET 8 and running Playwright browser tests through NUnit. It explains the transition from IWebHostBuilder to IHostBuilder and describes cross-platform, headless or headed testing across local systems, containers, and CI environments.

## Source excerpt

I've been doing not just Unit Testing for my sites but full on Integration Testing and Browser Automation Testing as early as 2007 with Selenium. Lately, however, I've been using the faster and generally more compatible Playwright. It has one API and can test on Windows, Linux, Mac, locally, in a container (headless), in my CI/CD pipeline, on Azure DevOps, or in GitHub Actions. For me, it's that last moment of truth to make sure that the site runs completely from end to end. I can write those Playwright tests in something like TypeScript, and I could launch them with node, but I like running end unit tests and using that test runner and test harness as my jumping off point for my .NET applications. I'm used to right clicking and "run unit tests" or even better, right click and "debug unit tests" in Visual Studio or VS Code. This gets me the benefit of all of the assertions of a full unit testing framework, and all the benefits of using something like Playwright to automate my browser. In 2018 I was using WebApplicationFactory and some tricky hacks to basically spin up ASP.NET within .NET (at the time) Core 2.1 within the unit tests and then launching Selenium. This was kind of janky and would require to manually start a separate process and manage its life cycle. However, I kept on with this hack for a number of years basically trying to get the Kestrel Web Server to spin up inside of my unit tests. I've recently upgraded my main site and podcast site to .NET 8. Keep in mind that I've been moving my websites forward from early early versions of .NET to the most recent versions. The blog is happily running on Linux in a container on .NET 8, but its original code started in 2002 on .NET 1.1. Now that I'm on .NET 8, I scandalously discovered (as my unit tests stopped working) that the rest of the world had moved from IWebHostBuilder to IHostBuilder five version of .NET ago. Gulp. Say what you will, but the backward compatibility is impressive. As such my code for Progr