Search code examples
c#premake

Premake4: how to create c# solution with unit test project


I'm new to Premake. I want to create a solution with 2 projects:

  • a class library project

  • a unit test project

I know the "kind" values are:

-ConsoleApp

-WindowedApp

-SharedLib

-StaticLib

I don't see a kind for unit test! There is a way to create this? Below what I've done...

solution "MySolution"
--framework ""
configurations { "Debug","Release" }
platforms { "x32","Universal" }
    project "MyProject1"
        targetname "MyProject1"
        location "MyProject1"
        kind "SharedLib"
        language "C#"
        files { "MyProject1/**.cs" } 
        excludes { "**/bin/**", "**/obj/**" } 
        links { "System","System.Core","Microsoft.CSharp","System.Runtime.Serialization","System.ComponentModel.DataAnnotations" }

        configuration "Debug"
            defines { "TRACE","DEBUG" }
            flags { "Symbols" }
            targetdir "../../../../../../../deploy/bin/"

        configuration "Release"
            defines { "TRACE" }
            flags { "Optimize" }
            targetdir "../../../../../../../deploy/bin/"

Solution

  • The solution i found is to create a class library project anyway, adding it references of a common unit tests project. Then Visual Studio allow you to execute those tests. You just lack of the unit tests project icon.

    I hope this will help other people!