RejectedSoftware Forums

Sign up

How to run unittests on dll project.

Greetings.

I have dub project with "targetType": "dynamicLibrary". When i run dub test it fails with message "Error executing command test: Command failed with exit code 1".

I think that the file __test__library__.exe actually dll, because I have a def-file (see Windows dll def-file ignored.).

I try to add

	"buildTypes": {
		"unittest": {
			"buildOptions": ["unittests", "debugMode", "debugInfo"],
			"excludedSourceFiles": ["*.def"]
		}

to dub.json, but still have def-file on link stage.

Thank you.

Re: How to run unittests on dll project.

On Wed, 30 Jul 2014 13:00:34 GMT, akaDemik wrote:

Greetings.

I have dub project with "targetType": "dynamicLibrary". When i run dub test it fails with message "Error executing command test: Command failed with exit code 1".

I think that the file __test__library__.exe actually dll, because I have a def-file (see Windows dll def-file ignored.).

I try to add

	"buildTypes": {
		"unittest": {
			"buildOptions": ["unittests", "debugMode", "debugInfo"],
			"excludedSourceFiles": ["*.def"]
		}

to dub.json, but still have def-file on link stage.

Thank you.

The "excludedSourceFiles" field for "buildTypes" doesn't have any effect on the package's source files (this needs to be better documented or emitted as a warning). What you can do is to create a separate "unittest" configuration:

{
  "name": "my-project",
  "configurations": [
    {
      "name": "library",
      "sourceFiles": "some.def",
      "targetType": "dynamicLibrary"
    },
    {
      "name": "unittest",
      "targetType": "executable"
    }
  ]
}

Re: How to run unittests on dll project.

Great idea. Unittesting work. Thank you.