Files
MusicPlayer/tests/mocks/test_helpers.gd
T
Sansan 4a275e6a88 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.
2026-10-01 20:55:09 +02:00

24 lines
749 B
GDScript

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