Jump to content
code34

OO_UNITTEST - Unit testing

Recommended Posts

OO UNITTEST
Lastest version: 0.2 by Code34

 

Description
OO UNITTEST is a class (object oriented) that permits to do unit test with OOP.h object code. Unit tests make the code more reliable and automatically run tests to check that all the functions of a program work as expected. This is a first version, it is not optimized but can lay the foundation to start doing things.

 

Github: https://github.com/code34/oo_unittest.vr

Reference: http://forums.bistudio.com/showthread.php?167980-Object-Oriented-SQF-Scripting-and-Compiling

Features:

- 2 set of methods to check method results: assert_equal & assert_not_equal

- check time of execution for each methods / types

- Dump into clipboard a global results

 

Licence:
Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author

 

Code Exemple

	/*
	Author: code34 nicolas_boiteux@yahoo.fr
	Copyright (C) 2018 Nicolas BOITEUX

	CLASS OO_UNITTEST
	
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. 
	*/

	#include "oop.h"

	call compile preprocessFileLineNumbers "oo_unittest.sqf";
	call compile preprocessFileLineNumbers "oo_helloworld.sqf";

	sleep 2;

	 _unittest = "new" call OO_UNITTEST;
	 _helloworld = "new" call OO_HELLOWORLD;

	 // should succeed cause return the good result
	_result = ["assert_equal", [_helloworld, "helloworld", "i got it", nil]] call _unittest;
	//shoud failed cause return the result not expected
	_result = ["assert_not_equal", [_helloworld, "helloworld", "i got it", nil]] call _unittest; 
	//should failed cause method doesn't exist
	_result = ["assert_equal", [_helloworld, "hellowor", "i got it", nil]] call _unittest; 
	//should passed cause object nil doesn't exist (arma will print an error message)
	_result = ["assert_equal", [nil, "helloworld", "i got it", nil]] call _unittest;

	 "dump" call _unittest;

Results of Dump

 

==> Function: helloworld
Condition: assert_equal
Params: None
Return expected: STRING (i got it)
Return: STRING (i got it)
Time: 0 ms
Result: SUCCESSED
Error Message: None
<==

==> Function: helloworld
Condition: assert_not_equal
Params: None
Return expected: STRING (i got it)
Return: STRING (i got it)
Time: 0 ms
Result: FAILED
Error Message: Result is not the one expected
<==

==> Function: hellowor
Condition: assert_equal
Params: None
Return expected: STRING (i got it)
Return: ARRAY (["ERROR UNDEF : OO_HELLOWORLD(""STRING"",""hellowor"")"])
Time: 0.000976563 ms
Result: FAILED
Error Message: Result is not the one expected
<==

==> Function: helloworld
Condition: assert_equal
Params: None
Return expected: STRING (i got it)
Return:  (any)
Time: 0 ms
Result: PASSED
Error Message: Object is not define
<==

Global Results:
============
Successed: 1
Passed: 1 
Failed: 2

 

Share this post


Link to post
Share on other sites

Hi

 

Working currently, on the next version. I believe i will unsupport the procedural code, except if anyone have the usage of it.

 

Most of the code was develop for oo way, it will be more clear and easiest to support.

Share this post


Link to post
Share on other sites

Hi :)

 

Just release the version 0.2 :

 

- delete useless procedural support

- fix code relative to nil return

- add more informations in dump report

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×