aprs.me/test/test_helper.exs
Graham McIntire a8e7b17ee1
Optimize test suite performance - 32.5% faster execution
Reduced test execution time from 21.2s to 14.3s through multiple optimizations:

1. Reduced test data size:
   - Memory efficiency test: 5000→1000 packets, smaller payloads (saved ~3.2s)
   - More focused test scenarios without sacrificing coverage

2. Reduced sleep times across test suite:
   - GPS movement tests: 100-500ms → 10-100ms
   - Broadcast supervisor tests: 50ms → 10ms
   - Packet consumer tests: 100-500ms → 20-50ms
   - Saved ~1-2 seconds total

3. Enabled parallel test execution:
   - Set max_cases to System.schedulers_online() * 2
   - Made DeviceIdentificationTest async
   - Made PasscodeTest and ConvertTest async
   - Better CPU utilization

4. Reduced assertion timeouts:
   - Changed from 1000ms to 200-500ms where appropriate
   - Faster failure detection

These optimizations maintain test reliability while significantly reducing
execution time. The occasional timing-sensitive LiveView test failures are
addressed with slightly more generous timeouts where needed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-21 09:23:07 -05:00

22 lines
1.1 KiB
Elixir

ExUnit.start(max_cases: System.schedulers_online() * 2)
Ecto.Adapters.SQL.Sandbox.mode(Aprsme.Repo, :manual)
# Configure Mox
Mox.defmock(Aprsme.PacketsMock, for: Aprsme.PacketsBehaviour)
Mox.defmock(Aprsme.PacketReplayMock, for: Aprsme.PacketReplayBehaviour)
Mox.defmock(PacketsMock, for: Aprsme.PacketsBehaviour)
# Set up default stubs for commonly used functions
Mox.stub(Aprsme.PacketsMock, :get_recent_packets_optimized, fn _opts -> [] end)
Mox.stub(Aprsme.PacketsMock, :get_nearby_stations, fn _lat, _lon, _exclude, _opts -> [] end)
# Ensure no external APRS connections during tests
Application.put_env(:aprsme, :disable_aprs_connection, true)
Application.put_env(:aprsme, :aprs_is_server, "mock.aprs.test")
Application.put_env(:aprsme, :aprsme_is_port, 14_580)
Application.put_env(:aprsme, :aprsme_is_login_id, "TEST")
Application.put_env(:aprsme, :aprsme_is_password, "-1")
Application.put_env(:aprsme, :aprsme_is_default_filter, "r/0/0/1")
Application.put_env(:aprsme, :packets_module, Aprsme.PacketsMock)
# AprsIsMock is automatically loaded from test/support via elixirc_paths