{"id":22350649,"url":"https://github.com/timmoth/elktest","last_synced_at":"2025-07-30T06:32:01.925Z","repository":{"id":62953507,"uuid":"562620605","full_name":"Timmoth/ElkTest","owner":"Timmoth","description":"Debug \u0026 test embedded systems using xunit integration tests and a Raspberry Pi Pico.","archived":false,"fork":false,"pushed_at":"2022-11-12T10:14:03.000Z","size":82,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-17T20:54:28.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Timmoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-06T22:11:28.000Z","updated_at":"2022-11-09T11:57:02.000Z","dependencies_parsed_at":"2023-01-22T02:00:35.197Z","dependency_job_id":null,"html_url":"https://github.com/Timmoth/ElkTest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FElkTest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FElkTest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FElkTest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Timmoth%2FElkTest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Timmoth","download_url":"https://codeload.github.com/Timmoth/ElkTest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228098260,"owners_count":17869033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T11:12:40.562Z","updated_at":"2024-12-04T11:12:41.287Z","avatar_url":"https://github.com/Timmoth.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elk Test\n\nElkTest enables users to debug \u0026 test embedded systems using xunit integration tests and a Raspberry Pi Pico.\n\n#### Benefits\n- Test production code on the physical device\n- No need to write any abstractions around device specific libraries\n- Simulating hardware inputs enables you to reliably test your code without physically recreating scenarios\n- Easily test networking / http requests\n- Device / Platform agnostic\n- View SUT serial output in test log\n\n### Setup:\n\n------------\n\n- clone the repo\n\n`git clone https://github.com/Timmoth/ElkTester.git\n`\n- Add Arduino pico to your board manager (file-\u003epreferences-\u003eadditional board manager urls) paste the following url\n\n`https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json`\n\n- Open the Elk test firmware in Arduino IDE\n\n`ElkTester/ElkTest/ElkFirmware/ElkFirmware.ino\n`\n- Plug in the Pico\n- Select the device + port \n- Flash the firmware\n- Add appsettings.json to test project\n- Fill out appsettings.json (ElkSUTDevice is optional)\n```json\n{\n  \"ElkTestDevice\": {\n    \"Port\": \"COM12\",\n    \"BaudRate\": 9600\n  },\n  \"ElkSUTDevice\": {\n    \"Port\": \"COM11\",\n    \"BaudRate\": 9600\n  }\n}\n```\n- Set appsettings 'copy to output directory' property to 'copy if newer'\n\n### How does it work?\n\n------------\nThere are two main components to the Elk Test framework:\n\n- The ElkTestDevice is a Raspberry Pi Pico flashed with the ElkTest firmware, each of its GPIO pins can be used to read / write data to / from the system under test. One pin of which is used to reset the SUT at the start of each test. The ElkTestDevice recieves requests from the test runner over a serial connection, these requests allow the tests to set inputs \u0026 assert on outputs.\n\n- The ElkApi is a dotnet minimal API configured at the start of each test that allows the SUT connected to the same local network to connect \u0026 make requests, the tests can then assert on the requests made.\n\nTests are written in dotnet using xunit, examples can be seen below.\n\n### Examples:\n------------\n\n\n[Echo](https://github.com/Timmoth/ElkTest/tree/main/Example/Sketches/echo \"Echo\")\n\nThe echo example sets analog pin 28 and asserts that the SUT in turn echos the same value to pin 27, the same logic is tested for digital pins 21 \u0026 20\n\nFlash the firmware to the SUT\n\n`ElkTester/Example/Sketches/echo/echo.ino`\n\nConnect the following pins:\n\n28 -\u003e 28 : analog input pin\n\n27 -\u003e 27 : analog output pin\n\n21 -\u003e 21 : digial input pin\n\n20 -\u003e 20 : digital output pin\n\n\nThe SUT reset is implemented in hardware by connecting an npn transistor collector to the SUT run pin, emitter to ground \u0026 base to ElkTestDevice pin 22.\n\n![image](https://user-images.githubusercontent.com/21103223/200683937-6679051d-e61f-4599-9eb8-116fd2d8415c.png)\n\nEnsure both devices are plugged in and configure the ElkTestDevice port in the test projects appsettings.json\n\n`ElkTester/Example/appsettings.json`\n\n```csharp\n //Arrange\nvar device = await _fixture.Setup(_output); // Connect to the ElkTestDevice \u0026 reset the SUT\n\n//Act\nawait device.SendAndWait(Device.Pins.Set(21, input)); // Set pin 21 high on the ElkTestDevice\n\nawait Task.Delay(1000); // Arbitrary wait to ensure sut loop has executed\n\n//Assert\nvar pinResponse = await device.SendAndWait(Device.Pins.Get(20)); // Read value from pin 20\nvar actualValue = int.Parse(pinResponse.Arguments[0]);\nAssert.Equal(expectedOutput, actualValue);\n```\n\n\n[Sample](https://github.com/Timmoth/ElkTest/blob/main/Example/Sketches/sample \"Sample\")\n\nSample digital pin values over time. \n\n\n\n[Serial](https://github.com/Timmoth/ElkTest/tree/main/Example/Sketches/serial \"Serial\")\n\nTests writing serial data to the SUT over USB \u0026 UART \u0026 asserts on the Serial output from the device.\n\n\n\n[Network](https://github.com/Timmoth/ElkTest/tree/main/Example/Sketches/network \"Network\")\n\nThe network example makes a sequence of POST, GET, PUT, DELETE requests.\n\nThis example uses [HttpRequester](https://github.com/Timmoth/HttpRequester \"HttpRequester\") to make HttpRequests on the SUT. See project readme for instructions on installing the library.\n\nCopy + Rename `arduino_secrets_example.h` =\u003e `arduino_secrets.h`\n\nUpdate the three arduino_secrets values.\nELKAPI_IP is the local IP address of the machine that runs the tests.\n\nFlash the firmware to the SUT\n`ElkTest/Example/Sketches/network/network.ino`\n\nThen run the tests! \n\n#### External examples\n\n[Outdoor Lights](https://github.com/Timmoth/OutdoorLights \"Outdoor Lights\")\n\n#### Upcoming\n- More complex examples\n- Improve documentation\n- Test PWM\n- Test I2C\n- Hardware pass / fail buttons\n- Hardware test output display\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimmoth%2Felktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimmoth%2Felktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimmoth%2Felktest/lists"}