简体   繁体   中英

How can i run Microsoft Unit Testing Framework for C++ using github actions?

i'm trying to run my unit test which is using the Microsoft Unit Testing Framework for C++ using Github actions.

I'v tried adding the DLL with the exe of the sln but it doesn't seem to work.

build:

runs-on: windows-latest

steps:
# using tmp v3 git branch 
- uses: actions/checkout@v3
# getting dependencies 
- name: getting dependencies
  working-directory: UnitTest
  run:  ./BuildTest.bat
# set up 
- name: set up
  working-directory: UnitTest
  run:  ./SetUpTest.bat
# adding msbuild path 
- name: add msbuild to PATH
  uses: microsoft/setup-msbuild@v1.1
# # building sln in release 
# - name: build release
#   run: msbuild Dare.sln /p:Configuration=Release
# building sln in debug 
- name: build debug
  run: msbuild Dare.sln /p:Configuration=Debug

# run unit test
- name: list
  working-directory: bin/Debug-windows-x86_64/DareEditor
  run : ls 

# run unit test
- name: run unit test
  working-directory: bin/Debug-windows-x86_64/DareEditor
  # run : ls 
  # run: ./DareEditor.exe /Platform:x64 ./x64\Debug\UnitTest1.dll
  # run: ./DareEditor.exe /Platform:x64 ./x64\Debug\UnitTest1.dll
  run: ./DareEditor.exe 

Went through the documentation and got it working.

Microsoft unit test - https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options?view=vs-2019

GitHub actions vstestconsole set up - https://github.com/marketplace/actions/commit-status-updater

runs-on: windows-latest

steps:
# using tmp v3 git branch 
- uses: actions/checkout@v3
# getting dependencies 
- name: getting dependencies
  working-directory: tools
  run:  ./BuildTest.bat
# set up 
- name: set up
  working-directory: tools
  run:  ./Setup.bat
# adding msbuild path 
- name: add msbuild to PATH
  uses: microsoft/setup-msbuild@v1.1
# set up vstest path
- name: Setup VSTest Path
  uses: darenm/Setup-VSTest@v1

# building sln in release 
- name: build release
  run: msbuild Dare.sln /p:Configuration=Release

# building sln in debug 
- name: build debug
  run: msbuild Dare.sln /p:Configuration=Debug

# run unit test
- name: run unit test
  working-directory: bin\Debug-windows-x86_64\DareUnitTest
  run: vstest.console.exe DareUnitTest.dll

Write unit tests for C/C++ in Visual Studio [!INCLUDE Visual Studio]

You can write and run your C++ unit tests by using the Test Explorer window. It works just like it does for other languages. For more information about using Test Explorer, see Run unit tests with Test Explorer.

[,NOTE] Some features such as Live Unit Testing. Coded UI Tests and IntelliTest aren't supported for C++.

Visual Studio includes these C++ test frameworks with no additional downloads required:

Microsoft Unit Testing Framework for C++ Google Test Boost.Test CTest You can use the installed frameworks, or write your own test adapter for whatever framework you want to use within Visual Studio. A test adapter integrates unit tests with the Test Explorer window. Several third-party adapters are available on the Visual Studio Marketplace. For more information, see Install third-party unit test frameworks.

Visual Studio 2017 and later (Professional and Enterprise)

C++ unit test projects support CodeLens.

Visual Studio 2017 and later (all editions)

Google Test Adapter is included as a default component of the Desktop development with C++ workload. It has a project template that you can add to a solution. Right-click on the solution node in Solution Explorer and choose Add > New Project on the shortcut menu to add the project template. It also has options you can configure via Tools > Options. For more information, see How to: Use Google Test in Visual Studio.

Boost.Test is included as a default component of the Desktop development with C++ workload. It's integrated with Test Explorer, but currently doesn't have a project template. It must be manually configured. For more information, see How to: Use Boost.Test in Visual Studio.

CTest support is included with the C++ CMake tools component, which is part of the Desktop development with C++ workload. For more information, see How to: Use CTest in Visual Studio.

Visual Studio 2015 and earlier

You can download the Google Test adapter and Boost.Test Adapter extensions on the Visual Studio Marketplace. Find them at Test adapter for Boost.Test and Test adapter for Google Test.

Basic test workflow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM