SpecSync plugins
SpecSync plugins can extend the functionality of SpecSync in order to support additional test sources, BDD tools and platforms.
SpecSync plugins can be implemented as NuGet packages containing .NET Standard 2.0 assemblies that are loaded by SpecSync during execution. In order to load a plugin, the plugin package has to be registered in the toolSettings/plugins
section of the configuration file. The list of all possible settings can be found in the toolSettings
configuration reference.
The GitHub repository https://github.com/specsolutions/specsync-sample-plugins contains several plugins with source-code that can be used directly for special synchronization situations or studied in order to create your own plugin.
The following example shows a simple plugin registration.
When registering a plugin, additional plugin parameters can be specified. Please contact the maintainer of the plugin for the specific values.
The plugins are loaded from nuget.org by default, but you can specify a folder or an alternative NuGet package feed in the packageSource
setting. If a plugin is loaded from a package feed SpecSync verifies the package and if it is not signed by Spec Solutions, you will be asked to confirm that you trust the package. To avoid the confirmation prompt, you can set the toolSettings/allowDownloadingThirdPartyPlugins
setting to true
. The downloaded plugins are cached to the SpecSync app data folder. The plugin cache folder can be changed using the toolSettings/pluginCacheFolder
setting.
Before SpecSync v3.4, the plugins were only loaded from local assemblies using the assemblyPath
setting of the plugin configuration. This setting is still available, but loading the plugins from NuGet packages is more convenient in most of the cases.
The following example shows how to load a SpecSync plugin from a private package feed.
Creating SpecSync plugins
The SpecSync plugins have to have a reference to the NuGet package SpecSync.PluginDependency
of the version that matches to the installed SpecSync version. This package contains the required interfaces and classes to create a SpecSync plugin. (Before SpecSync v3.4, the package SpecSync.AzureDevOps.PluginDependency
had to be used.)
If the plugin has further dependencies (e.g. depends on a custom parser), those have to be packaged to the plugin NuGet package. You can find an examle for this in the Excel Test Source plugin.
In order to test the plugins you might need to load multiple compilations of the same plugin package version. By default SpecSync caches the plugin packages by version, so for development we recommend disabling plugin cache using the toolSettings/disablePluginCache
setting.
The plugin assembly has to contain an assembly-level SpecSyncPlugin
attribute, that specifies the plugin class (e.g. [assembly: SpecSyncPlugin(typeof(CustomTestResultMatchPlugin))]
). The plugin class has to implement the ISpecSyncPlugin
interface that defines a single Initialize
method.
The plugin can register different services using the ServiceRegistry
property of the PluginInitializeArgs
passed in to the Initialize
method. One plugin can register multiple services.
The PluginInitializeArgs.Configuration
property can be used to modify or extend the configuration the user has provided (e.g. automatically register a custom field updater). The configuration can only be changed in the Initialize
method. Changing it later might have no impact or cause inconsistencies.
The following plugin class registers a custom test result matcher service.
Services that can be registered by a plugin
The following table contains the list of services that can be registered by a SpecSync plugin.
Using a plugin that customizes the BDD Project Loader, Local Test Case Container Parser, Local Test Case Analyzer or Local Test Case Container Updater services requires an Enterprise license. The Test Results Loader and Test Result Matcher services can be customized with Standard license or using the free plan.
Typical Plugin scenarios
The following table describes a few scenarios that can be supported by a SpecSync plugin.
In order to get advise for your goal, contact SpecSync support. We are happy to help.
Last updated