Automated testing for .NET and Angular with GitHub Actions

Automated testing works best when developers receive fast, reliable feedback without rebuilding the whole delivery process by hand. A GitHub Actions pipeline can restore dependencies, compile applications, execute .NET and Angular test suites, and publish artefacts whenever code is pushed or a pull request is opened. This approach turns continuous integration into a repeatable safety net for both server-side C# projects and TypeScript-based front ends.

The workflow below suits a repository containing an ASP.NET Core API and an Angular application, whether they live in a monorepo or closely related directories. It also reflects common needs in Australia, where teams in Sydney and Melbourne regularly maintain Angular interfaces for financial and e-commerce platforms, while distributed working arrangements make clear pull request checks especially valuable.

Prepare a repository that tests cleanly

Start with a predictable directory structure. For example, place the .NET solution under Api/Api.sln and the Angular application under Client/. Keep test projects close to the code they exercise, but make sure solution paths remain consistent across developer machines and CI. Relative paths are usually safer than absolute paths because they continue to work when a checkout directory changes.

The .NET side should pass dotnet test without relying on a developer’s local SQL Server instance. Unit tests can use xUnit, NUnit, or MSTest, while database integration tests can use Testcontainers or an isolated test database. Restore NuGet packages through the solution rather than restoring each project manually. This gives the workflow one predictable entry point and makes a failed dependency restore easier to diagnose.

The Angular project needs a committed package-lock.json and a non-interactive test script. A typical package.json entry looks like this:

{
  "scripts": {
    "test:ci": "ng test --watch=false --browsers=ChromeHeadless",
    "build": "ng build"
  }
}

Australian teams often describe a passing pipeline as “green” and a failed one as “broken”. In a stand-up, “all good” should mean tests genuinely ran, rather than being skipped because Chrome, the API, or a database was unavailable. If the project uses Angular’s newer Vitest-based test builder, adjust the script to match the installed Angular version instead of forcing the older Karma options.

Create a workflow for both stacks

GitHub Actions reads workflows from .github/workflows. The following example runs both suites for pushes and pull requests targeting main. Manual runs are also useful when diagnosing an unreliable build:

name: Test .NET and Angular

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: test-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  dotnet:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Install .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.0.x'
          cache: true
          cache-dependency-path: '**/*.csproj'

      - name: Restore packages
        run: dotnet restore Api/Api.sln

      - name: Run .NET tests
        run: >-
          dotnet test Api/Api.sln
          --configuration Release
          --no-restore
          --logger "trx;LogFileName=test-results.trx"

      - name: Upload test results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: dotnet-test-results
          path: Api/**/TestResults/**/*.trx
          if-no-files-found: ignore

  angular:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    defaults:
      run:
        working-directory: Client
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: npm
          cache-dependency-path: Client/package-lock.json

      - name: Restore packages
        run: npm ci

      - name: Build Angular application
        run: npm run build -- --configuration production

      - name: Run Angular tests
        run: npm run test:ci

The two jobs run in parallel, so a slow Angular suite does not delay the .NET results. The concurrency block cancels an older run when the same branch receives newer commits, preventing obsolete workflows from consuming runner minutes. The timeout-minutes value provides another guard against a hung test process.

Using npm ci instead of npm install ensures the Angular job installs exactly the dependency versions recorded in the lock file. The build step catches compilation and configuration errors that a narrow unit test might miss. Keep the actions/checkout, actions/setup-dotnet, actions/setup-node, and actions/upload-artifact references current, and consider pinning third-party actions to commit hashes in repositories with strict supply-chain requirements.

Make the checks fast and dependable

A pull request check is only useful when it is quick and trustworthy. NuGet and npm caching reduce repeated downloads, while small, focused test suites keep feedback below a few minutes. Avoid sharing mutable databases between test runs, seed deterministic test data, and ensure each test cleans up the files, containers, and records it creates. Parallel execution should improve throughput without making failures difficult to reproduce.

Keep the default contents: read permission unless the workflow genuinely needs more access. Store registry credentials, signing certificates, and deployment secrets in GitHub Actions secrets rather than repository variables or source files. Be especially careful with workflows triggered from forked pull requests, because untrusted code should not receive write access to the repository.

Australian engineering teams are often spread across different states, and daylight-saving changes can make a local schedule look inconsistent. GitHub-hosted runners use UTC, so keeping scheduled jobs in UTC and labelling logs with both UTC and Australian Eastern Time can prevent confusion. Public holidays also differ between states; a release plan that assumes one nationwide school holiday or bank holiday schedule will eventually surprise a team in Brisbane or Adelaide.

For organisations that also administer virtualised infrastructure, the operational principle is familiar: automated storage load balancing can stop workloads from crowding one host, much as sensible test sharding prevents a single slow suite from consuming every runner. This is particularly relevant to resource-sector teams in Perth that support private VMware estates as well as public cloud applications.

Commands and checks for a reliable pipeline

Run the same core commands locally before pushing a workflow. That separates application failures from runner configuration failures and saves time debugging through GitHub logs:

A short pipeline checklist helps keep the repository’s expectations consistent:

Most .NET workflow failures involve restore errors, incorrect working directories, or tests that expect local developer services. Read the first meaningful error rather than the final generic failure message. A package that exists on a private NuGet feed may require a named NuGet.config, and a test that creates records in SQL Server should use an isolated container or database rather than sharing an existing environment.

Angular failures commonly involve a missing headless browser, an accidental watch mode, or snapshot tests that depend on the machine’s locale. The standard GitHub Ubuntu image includes Chrome, but projects using Playwright may need an explicit browser installation. Date-sensitive tests deserve particular attention: CI normally runs in UTC, while Australian applications may display Australian Eastern Standard Time or Australian Eastern Daylight Time. Use timezone-aware dates rather than relying on the runner’s default locale.

Put the pipeline into daily use

Treat the workflow as part of the definition of done. Once it is stable, make the dotnet and angular jobs required checks in the repository settings. Developers should be able to reproduce a red result locally with the same restore, build, and test commands, while the workflow adds consistent browser versions, timing, and artefacts. A short note in the repository’s contribution guide is usually enough to explain when a job may be rerun and how to download its results.

Test fixtures often repeat the same mapping between API models, domain objects, and view models. The article on using AutoMapper in .NET explains how configuration can keep those transformations consistent. Reducing duplicated mapping code also reduces the number of places where a broken test fixture can conceal an application defect.

Create the workflow file, commit it with the application changes, and open a pull request to see both suites run together. From that first green check, expand coverage gradually, retain useful artefacts, and keep every pipeline failure visible until the team can reproduce and resolve it.