Accelergreat 3.0.0-beta.1

Prefix Reserved
This is a prerelease version of Accelergreat.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Accelergreat --version 3.0.0-beta.1                
NuGet\Install-Package Accelergreat -Version 3.0.0-beta.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Accelergreat" Version="3.0.0-beta.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Accelergreat --version 3.0.0-beta.1                
#r "nuget: Accelergreat, 3.0.0-beta.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Accelergreat as a Cake Addin
#addin nuget:?package=Accelergreat&version=3.0.0-beta.1&prerelease

// Install Accelergreat as a Cake Tool
#tool nuget:?package=Accelergreat&version=3.0.0-beta.1&prerelease                

uid: DeveloperDocumentation.Index

Ultra Fast Integration Tests

Accelergreat your tests.

Write and execute efficient and high-performance integration tests with ease using Accelergreat. It is a powerful .NET integration testing solution that automatically provisions and manages external dependencies for your tests, such as databases and APIs. Simplify your integration testing development process today with Accelergreat.

Overview

Accelergreat is a new and innovative testing platform designed to make integration testing easier.

Integration tests are essential to ensuring your code works and stays working. However, they have been challenging to write and run quickly in the past, earning a reputation as a problem area in the development world.

With Accelergreat we intend to make this a problem of the past by doing all the hard work for you.

Accelergreat currently supports xUnit and plans to support other test runners in the future.

Quality

We take pride in writing clean, quality code and use SonarCloud to scan our code for quality and security issues. This adds an extra layer of assurance that the code we ship is safe for your codebase to consume.

Quality gate

Security Rating Reliability Rating Maintainability Rating

Vulnerabilities Bugs Code Smells Technical Debt

Version

nuget v3.0.0-beta.1 net6.0 | net7.0

Accelergreat follows Semantic Versioning 2.0.0 for releases.

Packages

  • Accelergreat
  • Accelergreat.EntityFramework
  • Accelergreat.EntityFramework.InMemory
  • Accelergreat.EntityFramework.PostgreSql
  • Accelergreat.EntityFramework.Sqlite
  • Accelergreat.EntityFramework.SqlServer
  • Accelergreat.Web
  • Accelergreat.Xunit

Download

You can download Accelergreat packages from NuGet.org.

Configuration

Accelergreat supports the overriding of configuration for managed external dependencies such as databases.

Accelergreat will read the following files in the root level of your test projects that have the CopyToOutputDirectory setting set to Always or PreserveNewest:

  • accelergreat.json
  • accelergreat.{environment}.json

accelergreat.{environment}.json is supported to allow you to have different configurations for your local machine and CI pipeline.

{environment} is defined by setting an environment variable called ACCELERGREAT_ENVIRONMENT.

A schema has been provided for the configuration files. An example is shown below:

{
    "$schema": "https://cdn.accelergreat.net/configuration/3.0.0-beta.1/schema.json#"
}

Getting started

Components

To further understand components beyond what the below getting started guide shows, read about all the different components Accelergreat offers and to understand how to build your own components. Please follow this guide.

Example use case

Accelergreat has been designed with modularity and flexibility in mind. Whilst the example we have provided below may not match your specific use case, this example was chosen to best show the capabilities of Accelergreat. It should be an effective reference point for your own implementations.

To see other examples, you can look on our GitHub examples repo.

Database (Entity Framework SQL Server) + Web API integration test

Process

  1. Install the required packages
  2. Create the Accelergreat Components
    1. Database component class(es)
    2. Web Api component class(es)
  3. Create an Accelergreat Startup class
  4. Write your first Accelegreat Integration Test
Install the required packages
  • Accelergreat.EntityFramework.SqlServer
  • Accelergreat.Web
  • Accelergreat.Xunit
Create the Accelergreat Components

One of the core features of Accelergreat is the concept of components. A component represents a dependency for your tests. For example a database or a web API.

To further understand components beyond what this getting started guide shows, read about all the different components Accelergreat offers and to understand how to build your own components. Please follow this guide.

In our example we only need two components. One for our SQL Server database, and one for our Web API.

Database component

Create a class that inherits from SqlServerEntityFrameworkDatabaseComponent.

If you need to override any of the configuration values, see SqlServerEntityFrameworkConfiguration for the defaults.

using Accelergreat.EntityFramework.SqlServer;
using Microsoft.Extensions.Configuration;

namespace ExampleTestProject.Components;

public class ExampleDatabaseComponent : SqlServerEntityFrameworkDatabaseComponent<ExampleDbContext>
{
    public ExampleDatabaseComponent(IConfiguration configuration) : base(configuration)
    {
    }
}
Web API component

To interact with a .NET Web API in our integration tests, we need to create a Web App Component. (If you need to create a Microservice Architecture then follow this guide

Web app components run an instance of the API defined by the Web API startup class passed into the generic type parameter. The following steps will set up a component for you:

  1. Create a class derived from WebAppComponent.
  2. Inject the database connection string(s).
  3. [Optional] overriding appsettings.

Create the class derived from WebAppComponent

To create a Web App Component, create a class that inherits from WebAppComponent and pass in your Web API startup class as the generic type parameter.

Using a Startup class

using System.Collections.Generic;
using Accelergreat.Web;
using Accelergreat.Web.Extensions;
using Microsoft.Extensions.Configuration;

namespace ExampleTestProject.Components;

public class ExampleApiComponent : WebAppComponent<ExampleApi.Startup>
{
    protected override void BuildConfiguration(
        IConfigurationBuilder configurationBuilder,
        IReadOnlyAccelergreatEnvironmentPipelineData accelergreatEnvironmentPipelineData)
    {
        configurationBuilder.AddEntityFrameworkDatabaseConnectionString<ExampleDbContext>(
            "ExampleConnectionStringName", accelergreatEnvironmentPipelineData);
    }
}

Using a Program class (minimal APIs)

With the recent introduction of minimal apis in Aspnet core, you can now configure your application entirely in Program.cs . The Progam class is now in the global App Domain as an internal class of the Api assembly. If you are using miniminal apis then you will have to expose InternalsVisibleTo to the Test Assembly by editing the csproj file of the Api project:

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

...

	<ItemGroup>
		<InternalsVisibleTo Include="ExampleTestProject" />
	</ItemGroup>
...

using System;
using System.Collections.Generic;
using Accelergreat.EntityFramework.Extensions;
using Accelergreat.Environments;
using Accelergreat.Web;
using GuestAndActivities.Data.Contexts;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

namespace ExampleTestProject.Components;

internal class ExampleApiComponent : WebAppComponent<Program>
{

    protected override void BuildConfiguration(
            IConfigurationBuilder configurationBuilder,
            IReadOnlyAccelergreatEnvironmentPipelineData accelergreatEnvironmentPipelineData)
    {
        configurationBuilder.AddEntityFrameworkDatabaseConnectionString<ExampleDbContext>(
            "ExampleConnectionStringName", accelergreatEnvironmentPipelineData);
    }
}

Inject the database connection string(s)

In the examples above, we need to provide the database connection string to the Web API configuration a database connection string. We do this by overriding > BuildConfiguration and calling configurationBuilder.AddEntityFrameworkDatabaseConnectionString.

Create a Startup class

To create a working Accelergreat Start up class, follow these three important steps:

Create the class

Create a Startup class in your test project that implements IAccelergreatStartup.

Add the Assembly Attribute**

Accelergreat extends the xunit test framework, we have provided an assembly attribute that will instruct xunit to use the Accelergreat extended xunit test framework.

Important In the Startup file, add assembly attribute UseAccelergreatXunitTestFramework. Without this, the Startup code will not be executed.

Registering components in their dependent order (least dependent last)**

Lastly we need to register our components. In the ConfigureServices implementation, call services.AddAccelergreatComponent for each component as the type parameter.

Important The order in which components are initialized is defined by the order they are registered.

In our example, we need to initialize the database before the web API so that it can access the database connection string.

using Accelergreat.Xunit;
using Accelergreat.Xunit.Attributes;
using ExampleTestProject.Components;
using Microsoft.Extensions.DependencyInjection;

[assembly: UseAccelergreatXunitTestFramework]

namespace ExampleTestProject;

public class Startup : IAccelergreatStartup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddAccelergreatComponent<ExampleDatabaseComponent>();
        services.AddAccelergreatComponent<ExampleApiComponent>();
    }
}
Write your first Accelegreat Integration Test

Now that we've got everything set up, we're going to write our first test.

For this example, we'll also be using FluentAssertions to keep our assertion code clean and easy to read. We'll also follow the Arrange Act Assert (AAA) pattern:

Arrange Set up and insert our test data

Act Call the API endpoint

Assert Validate that the response data is correct

Create a test that that inherits from AccelergreatXunitTest.

using System.Threading.Tasks;
using Accelergreat.Environments.Pooling;
using Accelergreat.Xunit;
using ExampleTestProject.Components;
using FluentAssertions;
using Newtonsoft.Json;
using Xunit;

namespace ExampleTestProject.Tests;

public class ExampleTests : AccelergreatXunitTest
{
    public ExampleTests(IAccelergreatEnvironmentPool environmentPool) : base(environmentPool)
    {
    }

    [Fact]
    public async Task Examples_GetById_ReturnsCorrectExample()
    {
        // Arrange
        var exampleEntity = new ExampleEntity();

        var dbContextFactory = GetComponent<ExampleDatabaseComponent>().DbContextFactory;

        await using (var context = dbContextFactory.NewDbContext())
        {
            context.Set<ExampleEntity>().Add(exampleEntity);

            await context.SaveChangesAsync();
        }

        var httpClient = GetComponent<ExampleApiComponent>().CreateClient();

        // Act
        var httpResponseMessage = await httpClient.GetAsync($"examples/{exampleEntity.Id}");

        // Assert
        httpResponseMessage.IsSuccessStatusCode.Should().BeTrue();

        var body = await httpResponseMessage.Content.ReadAsStringAsync();

        var result = JsonConvert.DeserializeObject<ExampleEntity>(body)!;

        result.Id.Should().Be(exampleEntity.Id);
    }
}

Parallel execution (Premium feature)

One of the best features of Accelergreat is the ability to have your integration tests run in parallel, gaining massive performance improvements on multi-threaded machines.

It's as easy as config change. In your accelergreat configuration, make sure to add your client id and client secret:

{
  "$schema": "https://cdn.accelergreat.net/configuration/3.0.0-beta.1/schema.json#",
  "License": {
    "ClientId": "YourClientId",
    "ClientSecret": "YourClientSecret"
  }
}

Given credentials are provided and authentication is successful, Accelergreat will automatically execute in parallel when the following criteria is met:

By default, Accelergreat uses the max threads allowed from the number of logical processors on the machine. You can override this by setting the maxParallelThreads property in your xunit.runner.json configuration file.

Debugging in Visual Studio

Important When debugging tests in Visual Studio, do not click the stop button. Even if an exception occurs, click continue and let the test run through. If you click the stop button xunit will not run cleanup operations and dependencies will not be disposed of. This is especially important when debugging tests that use database dependencies.

Supported integrations

Entity Framework

  • In-Memory
  • Sqlite
  • SQL Server
  • PostgreSql

Application

  • .NET Web API: dotnet6+

Upcoming integrations

Entity Framework

  • MySql
  • CosmosDB

Application

  • Azure Functions
  • AWS Lambda

Questions & Feedback

Please email mail@accelergreat.net for any questions or feedback you may have.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Accelergreat:

Package Downloads
Accelergreat.EntityFramework

Accelergreat Entity Framework testing tools. Accelergreat is an integration testing package that helps to simplify and speed up the writing of integration tests, as well as taking away the challenging task of managing external dependencies.

Accelergreat.Xunit

Accelergreat xunit testing tools. Accelergreat is an integration testing package that helps to simplify and speed up the writing of integration tests, as well as taking away the challenging task of managing external dependencies.

Accelergreat.Web

Accelergreat web app testing tools. Accelergreat is an integration testing package that helps to simplify and speed up the writing of integration tests, as well as taking away the challenging task of managing external dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.1-beta 144 11/6/2024
3.1.0-beta 72 11/6/2024
3.0.0 871 7/13/2024
3.0.0-beta.2 624 2/12/2024
3.0.0-beta.1 66 2/9/2024
2.3.0-beta 620 1/23/2024
2.2.7 3,299 9/1/2023
2.2.6-beta 409 9/1/2023
2.2.5-beta 414 9/1/2023
2.2.4 486 9/1/2023
2.2.3-beta 1,228 3/26/2023
2.2.2-beta 511 3/26/2023
2.2.1-beta 520 3/25/2023
2.2.0-beta 484 3/25/2023
2.1.0-beta 497 3/24/2023
2.0.0 3,657 3/8/2023
2.0.0-beta02 540 3/1/2023
2.0.0-beta01 546 2/1/2023
1.7.2-beta 724 10/21/2022
1.7.1 3,853 10/18/2022
1.7.0 2,180 10/18/2022
1.7.0-beta 691 8/28/2022
1.6.4 2,580 8/27/2022
1.6.3-beta 1,545 8/14/2022
1.6.1-beta 776 8/12/2022
1.6.0-beta 724 7/18/2022
1.5.6-beta 846 7/4/2022
1.5.4-beta 799 6/25/2022
1.5.3-beta 712 6/24/2022
1.5.2-beta 719 6/23/2022
1.5.1-beta 675 6/20/2022
1.5.0-beta 688 6/20/2022
1.4.6 10,129 6/8/2022
1.4.5-beta 681 5/30/2022
1.4.4-beta 667 4/24/2022
1.4.3-beta 718 4/23/2022
1.4.2 4,902 3/15/2022
1.4.1-beta 797 3/2/2022
1.4.0-beta 689 2/17/2022
1.3.6 2,632 1/30/2022
1.3.5 2,473 1/30/2022
1.3.2-beta 729 1/27/2022
1.3.1-alpha 719 1/25/2022
1.3.0-alpha 742 1/25/2022
1.2.0 2,423 1/23/2022