I recently saw that Optimizely released A/B Testing Package (EPiServer.Marketing.Testing) for dotnet core, meaning you can now install the A/B Testing Addon on CMS12

Install

dotnet add package EPiServer.Marketing.Testing -v 3.0.0

Configure

But if you try running the site after the install, you might notice an error similar to this:

info: EPiServer.Framework.Initialization.InitializationEngine[0]
      Initialization started
fail: EPiServer.Framework.Initialization.InitializationEngine[0]
      Initialize action failed for 'Initialize on class EPiServer.Data.DataInitialization, EPiServer.Data, Version=12.4.2.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7'
      System.InvalidOperationException: Unable to resolve service for type 'EPiServer.Marketing.KPI.Dal.KpiDatabaseContext' while attempting to activate 'EPiServer.Marketing.KPI.Dal.BaseRepository'.
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters,
Boolean throwIfCallSiteNotFound)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
         at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters,
Boolean throwIfCallSiteNotFound)

The easiest way to fix this is by adding the following in your Startup.cs file:

services.AddABTesting(_configuration.GetConnectionString("EPiServerDB"));

Once you do that the site should load as usual and when you make any changes to your content, under the publish menu you should see the A/B Testing entry in it’s usual location

PS: If you are missing the _configuration in your Startup.cs update the constructor to inject the dependency as follows:

public Startup(IWebHostEnvironment webHostingEnvironment,IConfiguration configuration)
{
    _webHostingEnvironment = webHostingEnvironment;
    _configuration = configuration;
}