I'm currently implementing a .NET wrapper for a Java library by using JNI to start the JavaVM and interacting with Java classes. To be on the save side, I'd like to have unit tests for my code.
我目前正在通过使用JNI启动JavaVM并与Java类交互来实现Java库的.NET包装器。为了保存,我想对我的代码进行单元测试。
The Problem I'm facing now is, you only can start the Java VM once per process. There is no possibility to unload the JVM.
我现在面临的问题是,每个进程只能启动一次Java VM。无法卸载JVM。
This makes it rather difficult to write unit tests that are actually clean.
这使得编写实际上干净的单元测试变得相当困难。
Some specs: .NET/Java interface: done in C++/cli Unit testing lib: NUnit Unit testing code: C#
一些规范:.NET / Java接口:用C ++ / cli完成单元测试lib:NUnit单元测试代码:C#
Any tips?
Regards, Dominik
1 个解决方案
#1
You could create an ad-hoc .Net test application, that would run on its own process.
您可以创建一个ad-hoc .Net测试应用程序,该应用程序将在其自己的进程上运行。
Your NUnit tests would thus launch this process (even in command line), let it actually run the tests, and the return the value as std output. IOW, keep it simple and launch many processes.
因此,您的NUnit测试将启动此过程(即使在命令行中),让它实际运行测试,并将值作为std输出返回。 IOW,保持简单并启动许多流程。
#1
You could create an ad-hoc .Net test application, that would run on its own process.
您可以创建一个ad-hoc .Net测试应用程序,该应用程序将在其自己的进程上运行。
Your NUnit tests would thus launch this process (even in command line), let it actually run the tests, and the return the value as std output. IOW, keep it simple and launch many processes.
因此,您的NUnit测试将启动此过程(即使在命令行中),让它实际运行测试,并将值作为std输出返回。 IOW,保持简单并启动许多流程。