GameCorder.net

このエントリーをはてなブックマークに追加

How to set unit test environment in xcode9 with cocos2dx

Let's set up unit test environment in xcode9.

Launch xcode and tap project and click + icon

Select "Ios Unit Testing Bundle".
And tap next.

next scene set unit testing bundle.
put "target to be tested" in your test module.
In my case select Language objective-c.

created unit test module
rename test module class .m to .mm for c++.

include cocos2dx module

Next.include need module to test.
In this case I want to test Utils.cpp.
add compile source with Utils.cpp

Like top image
Select test Target module.
select "Build Phases" next "Compile Sources"
click "+" select "Utils.cpp"
compile sources setting is end

Write unit test code and run

#include "Utils.hpp".
And write test code.

You can see run button left to function code in above image.
If click button run test code.

This is available in cocos2dx 3.15.1