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
![](../img/set_compile_source_xcode.png)
Select "Ios Unit Testing Bundle".
And tap next.
![](../img/select_unit_test_xcode.png)
next scene set unit testing bundle.
put "target to be tested" in your test module.
In my case select Language objective-c.
![](../img/setup_xcode_unittest.png)
created unit test module
rename test module class .m to .mm for c++.
![](../img/unit_test_module_xcode.png)
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.
![](../img/run_unit_test_in_xcode.png)
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