mercredi 13 mai 2020

NUnit error while loading .dll which was build by CSharpCodeProvider

Nunit-tool throws the following exception: This assembly was not built with any known testing framework

I have to build a .dll by CSharpCodeProvider like this:

public static void Main(string[] args)
{
  var provider = new CSharpCodeProvider();
  var options = new CompilerParameters
  {
     OutputAssembly = @"TestCases.dll"
  };

  string AssemblyTemplateClass= "public class AssemblyTemplate {}";
  provider.CompileAssemblyFromSource(options, new[] { source });
}

The AssemblyTemplate-Class looks like:

[TestFixture]
public class AssemblyTemplate
{
  [Test, TestCaseSource("TestSelection")]

  //Testing-Method

  public static String[] TestSelection()
  {
    var path = @"C:\Users\user\Desktop\TestCases.txt";
    return File.ReadAllLines(path);
  }
}

Within this Assembly class I´m using the NUnit framework. If I create an extra Class Library Project with this class, there is no error within NUnit-tool. But I have to create a .dll programmatically during my application console.

Aucun commentaire:

Enregistrer un commentaire