Files
Battle-for-Tismo/tests/run_tests.js
T

95 lines
3.0 KiB
JavaScript

// Test runner. Instantiates every suite, calls its `test_*` methods and prints
// a summary, exiting non-zero when anything fails. Run with:
//
// node tests/run_tests.js
import { HexTest } from "./hex_test.js";
import { NoiseTest } from "./noise_test.js";
import { RngTest } from "./rng_test.js";
import { DataTest } from "./data_test.js";
import { MapGeneratorTest } from "./map_generator_test.js";
import { HexPathfinderTest } from "./hex_pathfinder_test.js";
import { TerrainStatsTest } from "./terrain_stats_test.js";
import { EconomyTest } from "./economy_test.js";
import { TextFormatTest } from "./text_format_test.js";
import { GameClockTest } from "./game_clock_test.js";
import { LoginManagerTest } from "./login_manager_test.js";
import { RulesTest } from "./rules_test.js";
import { CombatTest } from "./combat_test.js";
import { SiegeTest } from "./siege_test.js";
import { GameStateTest } from "./game_state_test.js";
import { GameStateBuildingsTest } from "./game_state_buildings_test.js";
import { GameStateGovernmentTest } from "./game_state_government_test.js";
import { GameStateTechnologyTest } from "./game_state_technology_test.js";
import { GameServerTest, GameServerOrdersTest, GameServerLoginTest, GameServerLobbyTest } from "./game_server_test.js";
import { ServerStaticTest, ServerLoopTest, ServerProtocolTest } from "./server_test.js";
import { WebSocketProtocolTest } from "./websocket_test.js";
import { NetTest } from "./net_test.js";
import { MapViewTest } from "./map_view_test.js";
import { TrainModalTest, BuildingsModalTest, NationModalTest } from "./modals_test.js";
import { GameScreenTest } from "./game_screen_test.js";
import { AppTest } from "./app_test.js";
const SUITES = [
HexTest,
NoiseTest,
RngTest,
DataTest,
MapGeneratorTest,
HexPathfinderTest,
TerrainStatsTest,
EconomyTest,
TextFormatTest,
GameClockTest,
LoginManagerTest,
RulesTest,
CombatTest,
SiegeTest,
GameStateTest,
GameStateBuildingsTest,
GameStateGovernmentTest,
GameStateTechnologyTest,
GameServerTest,
GameServerOrdersTest,
GameServerLoginTest,
GameServerLobbyTest,
ServerStaticTest,
ServerLoopTest,
ServerProtocolTest,
WebSocketProtocolTest,
NetTest,
MapViewTest,
TrainModalTest,
BuildingsModalTest,
NationModalTest,
GameScreenTest,
AppTest,
];
let passed = 0;
const failures = [];
for (const Suite of SUITES) {
const instance = new Suite();
const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(instance))
.filter((name) => name.startsWith("test_") && name !== "constructor")
.sort();
for (const method of methods) {
try {
await instance[method]();
passed += 1;
} catch (error) {
failures.push(`${Suite.name}::${method}: ${error.message}`);
}
}
}
console.log("");
if (failures.length === 0) {
console.log(`PASS: ${passed} test(s) passed.`);
process.exit(0);
}
console.log(`FAIL: ${passed} passed, ${failures.length} failed.`);
for (const failure of failures) console.log(` - ${failure}`);
process.exit(1);