Add GdUnit4 testing framework with comprehensive test coverage
- Add GdUnit4 v6.2.1 framework in addons/gdUnit4/ - Create test directory structure (tests/unit/, tests/integration/, tests/mocks/) - Add unit tests for MusicPlayer.gd (8 tests) - Add unit tests for MainWindow.gd (15+ tests) - Add unit tests for Settings.gd (5 tests) - Add unit tests for Playlist.gd (11 tests) - Add integration tests for full flow (10+ tests) - Add MockHTTPRequest for HTTP request mocking - Add TestHelpers with utility functions - Add Gitea Actions CI workflow (.gitea/workflows/test.yml) - Add .runsettings for GdUnit4 CLI configuration - Add run_tests.sh for convenient test execution - Add TESTING.md with comprehensive documentation - Add TESTING_PLAN.md with implementation details - Update .gitignore for test artifacts - Enable GdUnit4 plugin in project.godot Features: - Test button functionality (play, pause, search, sync, etc.) - Mock REST API requests to server - Test complete application flows - Run tests in CI (headless mode) - Run tests in GUI for visual feedback - JUnit XML and HTML test reports Generated by OpenCode AI assistant.
This commit is contained in:
1 parent
9a91d969bd
commit
ab338b0696
15 files changed
+2146
-1
No files matched your search
@@ -0,0 +1,37 @@
|
||||
class_name MockHTTPRequest
|
||||
extends HTTPRequest
|
||||
|
||||
signal mock_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray)
|
||||
|
||||
var mock_responses: Dictionary = {}
|
||||
var request_count: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
request_completed.connect(_on_request_completed)
|
||||
|
||||
func _on_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
pass
|
||||
|
||||
func add_mock_response(url: String, response_code: int = 200, body: PackedByteArray = PackedByteArray(), headers: PackedStringArray = PackedStringArray()) -> void:
|
||||
mock_responses[url] = {
|
||||
"code": response_code,
|
||||
"body": body,
|
||||
"headers": headers
|
||||
}
|
||||
|
||||
func request(url: String, headers: PackedStringArray = [], method: int = HTTPClient.METHOD_GET, body: PackedByteArray = PackedByteArray()) -> int:
|
||||
request_count += 1
|
||||
if mock_responses.has(url):
|
||||
var response = mock_responses[url]
|
||||
emit_signal("request_completed", OK, response.code, response.headers, response.body)
|
||||
return OK
|
||||
else:
|
||||
emit_signal("request_completed", FAILED, 404, [], PackedByteArray())
|
||||
return FAILED
|
||||
|
||||
func get_request_count() -> int:
|
||||
return request_count
|
||||
|
||||
func reset() -> void:
|
||||
request_count = 0
|
||||
mock_responses.clear()
|
||||
@@ -0,0 +1,23 @@
|
||||
class_name TestHelpers
|
||||
extends RefCounted
|
||||
|
||||
static func create_mock_audio_stream() -> AudioStreamMP3:
|
||||
var stream = AudioStreamMP3.new()
|
||||
stream.data = PackedByteArray()
|
||||
return stream
|
||||
|
||||
static func create_test_song_object(song_no: int = 1, soundtrack: String = "Test Soundtrack", song_title: String = "Test Song") -> SongObject:
|
||||
var song_obj = SongObject.new()
|
||||
song_obj.song_number = song_no
|
||||
song_obj.soundtrack_title = soundtrack
|
||||
song_obj.song_title = song_title
|
||||
song_obj.song = create_mock_audio_stream()
|
||||
return song_obj
|
||||
|
||||
static func setup_test_environment() -> void:
|
||||
Settings.is_debug = true
|
||||
Settings.stop_after_current = false
|
||||
Settings.auto_repeat_song = false
|
||||
|
||||
static func cleanup_test_environment() -> void:
|
||||
Settings.is_debug = false
|
||||
Reference in new issue
Block a user