Swiss Life | OSS

Swiss Life | OSS

  • Blog
  • GitHub

โ€บAll blog posts

All blog posts

  • Squadron - First public release
  • Snapshooter - Mismatch Compare in Visual Studio
  • First SwissLife OSS - Snapshooter

Squadron - First public release

November 29, 2019

Philippe Birbaum

Philippe Birbaum

Last month we have released our first Open Source version of Squadron. ๐ŸŽ‰ Squadron is a testing framework which makes ist extremely easy to write integration & system tests against resources that run in a container or in the cloud.

The tool has been internally developed at Swiss Life and was heavily used to write tests against SQL Server and MongoDB for more than one year now.

With the new Open Source version 0.5 we have now added many more providers and plan do add even more.

Supported resources

ProviderNuget Package
MongoSquadron.MongoDb
Mongo Replica SetSquadron.MongoDb
SQL ServerSquadron.SqlServer
Elastic SearchSquadron.ElasticSearch
PostgreSQLSquadron.PostgreSql
RedisSquadron.Redis
RabbitMQSquadron.RabbitMQ
Azure StorageSquadron.AzureStorage
Azure ServiceBusSquadron.AzureCloudServiceBus
GenericSquadron.Core
ComposeSquadron.Compose

Azure Cloud resources

Whenever possible we recommend to use a container resource to use with Squadron, but there are some cases when there is no container replacement for a cloud service. An an example is Azure Storage where the basic features are available using the Azurite emulator, but some more advanced features like leases are only available where using the "Real" cloud service.

For this we have build the functionality the manage Azure services using the management API's. Squadron will automatically provision new resources and delete them when the test has completed. Another way is to use an existing azure resource and provision some entities for the test and remove them after. This can save some time as creating resource is usually a expensive operation. The first resource we have implemented for Azure is Azure Service Bus.

Getting started

  1. Create a new xUnit Project
dotnet new xunit -name squadron-quickstart
  1. Install the Squadron nuget package Mongo for within your test project:
dotnet add package Squadron.Mongo

Inject and use the MongoResource into your test class constructor:

public class UserRepositoryTests : IClassFixture<MongoResource>
{
    private readonly MongoResource _mongoResource;

    public UserRepositoryTests(MongoResource mongoResource)
    {
        _mongoResource = mongoResource;
    }

    [Fact]
    public async Task UserRepository_Add_AddedUser()
    {
        //arrange
        var user = User.CreateSample();
        IMongoDatabase db = _mongoResource.CreateDatabase();
        var repo = new UserRepository(db);

        //act
        await repo.AddAsync(user);

        //assert
        User createdUser = await GetUserAsync(db, user.Id);
        createdUser.Should().BeEquivalentTo(user);
    }
}

You can find more quick starts and samples in our docs.

Roadmap

More resources

With future releases we plan to add the following resources to squadron:

  • Kafka
  • RavenDB
  • MySQL
  • Azure Storage
  • Azure Event Hub

Testing framework support

The current release only supports xUnit as the testing framework. We are now in the process of abstracting the initialization of resources to make it framework independent. NUnit is the next framework on our list to be supported, and of course with the new abstraction you can use Squadron in any .NET Core app.

Samples

We are building a sample solution to show some more complex scenarios using Squadron. Especially using the Compose Resource and integration with Selenium tests.

If you have some ideas for improvements or you'd like to see other integrations in Squadron feel free to create an issue or submit a pull request.

You can also reach out to us using Slack channel.

Recent posts
  • Supported resources
  • Azure Cloud resources
  • Getting started
  • Roadmap
    • More resources
    • Testing framework support
    • Samples

Projects

SnapshooterSquadronMagnet

Community

Contributor License AgreementsCode of ConductTwitterSlack

More

BlogGitHub
Swiss Life OSSSwiss Life | OSS
Copyright ยฉ 2019 Swiss Life Developer