This is a documentation for Board Game Arena: play board games online !
Testing by developer: Difference between revisions
Victoria La (talk | contribs) (Created page with "--- this page is under consructon --- When you develop a game yuo obviously need to test it, this page collects the info about testing in one place == Manual Testing on BGA == For manual testing most important things to know is * how to start/stop game in one click * how to switch between players in one click * how to save/restore the game state * how to construct the game state automatically All of these described here [Tools and tipsof BGA Studio] == Manual Testing...") |
m (Add a trailing slash to the env var declaration example for APP_GAMEMODULE_PATH.) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
When you develop a game | When you develop a game you obviously have to test it, this page collects the info about testing in one place | ||
== Manual Testing on BGA == | == Manual Testing on BGA == | ||
Line 10: | Line 9: | ||
* how to save/restore the game state | * how to save/restore the game state | ||
* how to construct the game state automatically | * how to construct the game state automatically | ||
All of these described here | All of these described here https://en.doc.boardgamearena.com/Tools_and_tips_of_BGA_Studio | ||
There is also HUGE checklist of things you need to test manually which you may not even thing about, defined here https://en.doc.boardgamearena.com/Pre-release_checklist | |||
== Manual Testing locally == | == Manual Testing locally == | ||
'''HTML/CSS''' | |||
At this era the file sync is almost instant so you do not save much by doing this locally, however if internet is a challenge - here are some tips | |||
https://en.doc.boardgamearena.com/Tools_and_tips_of_BGA_Studio#Speed_up_CSS_development_and_layout | |||
'''PHP''' | |||
You can run and debug php locally using tip https://en.doc.boardgamearena.com/BGA_Studio_Cookbook#Creating_a_test_class_to_run_PHP_locally | |||
== Automated Testing == | == Automated Testing == | ||
'''JavaScript''' | |||
I have not tried it. If you have any success please add instructions here. Theoretically its is possible to hook something like selenium to studio games | |||
'''PHP''' | |||
* Install php-cli (you need a verson that bga runs - | You can hook up phpunit and write unit tests for php, for that you need stubs for framework functions and classes. | ||
* Install phpunit, if you use composer DO not | |||
* Install php-cli (you need a verson that bga runs - consult https://en.doc.boardgamearena.com/Studio#Software_Versions) | |||
* Install phpunit matching this specific php version (the latest does not work), if you use composer DO not install it in the game directory - install it somewhere else | |||
* Create directory modules/tests | * Create directory modules/tests | ||
** If you do file sync - | ** If you do file sync - exclude it from the sync | ||
* Checkout/get stubs from github (see https://en.doc.boardgamearena.com/Setting_up_BGA_Development_environment_using_VSCode) | * Checkout/get stubs from github (see https://en.doc.boardgamearena.com/Setting_up_BGA_Development_environment_using_VSCode), i.e | ||
** git clone git@github.com:elaskavaia/bga-sharedcode.git | ** git clone git@github.com:elaskavaia/bga-sharedcode.git | ||
* So main issue | * So the main issue - php unit needs to find the parts of bga framework which is not available, in this example we will use stubs above | ||
* Create autoload.php | * Create autoload.php in modules/ directory | ||
<pre> | <pre> | ||
<?php | <?php | ||
Line 49: | Line 60: | ||
?> | ?> | ||
</pre> | </pre> | ||
* Set env var APP_GAMEMODULE_PATH to point where stubs are in this case | * Set env var APP_GAMEMODULE_PATH to point to where stubs are, in this case APP_GAMEMODULE_PATH=$HOME/git/bga-sharedcode/misc/ | ||
* Create a test in tests/ folder (see phpunit examples) | * Create a test in tests/ folder (see phpunit examples) | ||
* Run phpunit --bootstrap autoload.php tests/ | <pre> | ||
<?php declare(strict_types=1); | |||
use PHPUnit\Framework\TestCase; | |||
require_once "../mygame.game.php"; | |||
class GameUT extends MyGame { | |||
function __construct() { | |||
parent::__construct(); | |||
include "../material.inc.php"; | |||
} | |||
// override/stub methods here that access db and stuff | |||
} | |||
final class GameTest extends TestCase { | |||
public function testGameProgression() { | |||
$m = new GameUT(); | |||
$this->assertEquals(0,$m->getGameProgression()); | |||
} | |||
// more tests | |||
} | |||
</pre> | |||
* Run this from modules/ dir (this assumes env var above already set globally) | |||
phpunit --bootstrap autoload.php tests/ | |||
== Play testing on studio == | == Play testing on studio == |
Latest revision as of 20:53, 24 March 2024
When you develop a game you obviously have to test it, this page collects the info about testing in one place
Manual Testing on BGA
For manual testing most important things to know is
- how to start/stop game in one click
- how to switch between players in one click
- how to save/restore the game state
- how to construct the game state automatically
All of these described here https://en.doc.boardgamearena.com/Tools_and_tips_of_BGA_Studio
There is also HUGE checklist of things you need to test manually which you may not even thing about, defined here https://en.doc.boardgamearena.com/Pre-release_checklist
Manual Testing locally
HTML/CSS At this era the file sync is almost instant so you do not save much by doing this locally, however if internet is a challenge - here are some tips https://en.doc.boardgamearena.com/Tools_and_tips_of_BGA_Studio#Speed_up_CSS_development_and_layout
PHP You can run and debug php locally using tip https://en.doc.boardgamearena.com/BGA_Studio_Cookbook#Creating_a_test_class_to_run_PHP_locally
Automated Testing
JavaScript
I have not tried it. If you have any success please add instructions here. Theoretically its is possible to hook something like selenium to studio games
PHP
You can hook up phpunit and write unit tests for php, for that you need stubs for framework functions and classes.
- Install php-cli (you need a verson that bga runs - consult https://en.doc.boardgamearena.com/Studio#Software_Versions)
- Install phpunit matching this specific php version (the latest does not work), if you use composer DO not install it in the game directory - install it somewhere else
- Create directory modules/tests
- If you do file sync - exclude it from the sync
- Checkout/get stubs from github (see https://en.doc.boardgamearena.com/Setting_up_BGA_Development_environment_using_VSCode), i.e
- git clone git@github.com:elaskavaia/bga-sharedcode.git
- So the main issue - php unit needs to find the parts of bga framework which is not available, in this example we will use stubs above
- Create autoload.php in modules/ directory
<?php define("APP_GAMEMODULE_PATH", getenv('APP_GAMEMODULE_PATH')); spl_autoload_register(function ($class_name) { switch ($class_name) { case "APP_GameClass": //var_dump($class_name); //var_dump(APP_GAMEMODULE_PATH); include APP_GAMEMODULE_PATH."/module/table/table.game.php"; break; default: include $class_name . ".php"; break; } }); ?>
- Set env var APP_GAMEMODULE_PATH to point to where stubs are, in this case APP_GAMEMODULE_PATH=$HOME/git/bga-sharedcode/misc/
- Create a test in tests/ folder (see phpunit examples)
<?php declare(strict_types=1); use PHPUnit\Framework\TestCase; require_once "../mygame.game.php"; class GameUT extends MyGame { function __construct() { parent::__construct(); include "../material.inc.php"; } // override/stub methods here that access db and stuff } final class GameTest extends TestCase { public function testGameProgression() { $m = new GameUT(); $this->assertEquals(0,$m->getGameProgression()); } // more tests }
- Run this from modules/ dir (this assumes env var above already set globally)
phpunit --bootstrap autoload.php tests/
Play testing on studio
To play test on studio you can use your test accounts dev0... dev9. You can give some of these account to other people just make sure you change the password. You should not encourage other people who are not developers to create studio account, this is against bga policy.