我正在尝试从 C# 开始这项工作:
C头:
typedef void (LogFunc) (const char *format, va_list args);
bool Init(uint32 version, LogFunc *log)
Run Code Online (Sandbox Code Playgroud)
C# 实现:
static class NativeMethods
{
[DllImport("My.dll", SetLastError = true)]
internal static extern bool Init(uint version, LogFunc log);
[UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true)]
internal delegate void LogFunc(string format, string[] args);
}
class Program
{
public static void Main(string[] args)
{
NativeMethods.Init(5, LogMessage);
Console.ReadLine();
}
private static void LogMessage(string format, string[] args)
{
Console.WriteLine("Format: {0}, args: {1}", format, DisplayArgs(args));
}
}
Run Code Online (Sandbox Code Playgroud)
这里发生的是NativeMethods.Init调用回调LogMessage …
我正试图找到一种从mstest迁移到xunit的方法,并且仍然受益于IDE集成,这使我首先选择了mstest.Gallio似乎完成了这个崇高的目标,而且它是免费的(不想要Reshaper或TestDriven.net).但我不能让代码覆盖工作.
我的解决方案包含两个项目:项目SUT(我需要测试的程序集)和项目SUT.Tests这是一个VS测试项目(这允许Gallio在VS的测试视图中显示xunit测试).我在Local.testSettings中为SUT.dll启用了代码覆盖,并且检测已到位.测试运行完成后,没有代码覆盖率.代码覆盖率结果窗口报告:生成空结果:未使用任何检测二进制文件.查看任何仪器问题的测试运行详细信息.不幸的是,测试运行细节不包含任何"仪器问题".我尝试取消选中仪器组件复选框并重新运行单元测试; 同样的结果.
知道什么是错的吗?
我的设置:
- Windows 7 x64
- VS 2010 Premium(SP1)
- xUnit 1.8
- Gallio 3.3.1 x64(安装程序,不是zip)
unit-testing code-coverage gallio xunit.net visual-studio-2010