Posts

Showing posts from January, 2021

C++ unit testing & CI integration in GitHub (2/2)

Image
Based on the previous post , we are able to integrate our Android JNI project with CI tools, Circle-CI and GitHub Actions. However, we still have a little unperfected because we were unable to enable an Android emulator running for Android JNI unit tests. Now, I think I got a solution, it is using Android Emulator Runner . Add a job for Android Emulator When I first saw the instruction from  Android Emulator Runner , I was thinking it should be super easy and should not take me an hour, but I was wrong... Let's use the sample config from that Android Emulator Runner link. jobs: test: runs-on: macos-latest steps: - name: checkout uses: actions/checkout@v2 - name: run tests uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 script: ./gradlew connectedCheck This test job is run on a Mac OS machine and going to checkout your code from the repo and launch an Android emulators. I am supposed Linux and Windows machine a...

C++ unit testing & CI integration in GitHub (I/2)

Image
I am working on a side project,  Vulkan-Android , that is based on Java, JNI, C++, and Vulkan for Android platform. It also uses my C++ math library. Therefore, the requirement of my build and unit tests are around C++. First of all, I would make sure the unit tests in local are run properly. C++ unit test on Mac OS On Mac OS, I think the most convenient way to do unit testing for C++ is writing XCT in Xcode. In the beginning, we need to create a test plan in Xcode. It will helps us create a schema, then, in the test navigator, create a new Unit Test Target. Due to XCT was originally designed for Objective-C or Swift, if we wanna test our C++ code, we need a workaround by making the file extension name to be *.mm . And then, write down the unit tests as below: #import <XCTest/XCTest.h> #include "Vector3d.h" using namespace gfx_math; @interface testVector3D : XCTestCase @end @implementation testVector3D - (void)setUp { // Put setup code here. This method is cal...