I’m brand new on Platformio, and was trying to follow the Get started with Arduino and ESP32-DevKitC: debugging and unit testing tutorial everything was good until I tried the unit test section. When I ran the test this of many error messages comes up.
I tried to run tests with pio test
command and same output again.
test/test_main.cpp
#include "esp32-hal.h"
#include "unity_internals.h"
#include <Arduino.h>
#include <unity.h>
String STR_TO_TEST;
void setUp(void) { STR_TO_TEST = "Hello, world"; }
void tearDown(void) { STR_TO_TEST = ""; }
void test_string_concat(void) {
String hello = "Hello, ";
String world = "world!";
TEST_ASSERT_EQUAL_STRING(STR_TO_TEST.c_str(), (hello + world).c_str());
}
void test_string_substring(void) {
TEST_ASSERT_EQUAL_STRING("Hello", STR_TO_TEST.substring(0, 5).c_str());
}
void test_string_index_of(void){
TEST_ASSERT_EQUAL(7, STR_TO_TEST.indexOf('w'));
}
void test_string_equal_ignore_case(void){
TEST_ASSERT_TRUE(STR_TO_TEST.equalsIgnoreCase("HELLO, WORLD!"));
}
void test_string_to_upper_case(void) {
STR_TO_TEST.toUpperCase();
TEST_ASSERT_EQUAL_STRING("HELLO, WORLD!", STR_TO_TEST.c_str());
}
void test_string_replace(void){
STR_TO_TEST.replace('!', '?');
TEST_ASSERT_EQUAL_STRING("Hello, world?", STR_TO_TEST.c_str());
}
void setup(){
delay(2000);
UNITY_BEGIN();
RUN_TEST(test_string_concat);
RUN_TEST(test_string_substring);
RUN_TEST(test_string_index_of);
RUN_TEST(test_string_equal_ignore_case);
RUN_TEST(test_string_to_upper_case);
RUN_TEST(test_string_replace);
UNITY_END();
}
void loop(){
}
platformio.ini:
[env:dev]
############################
board = esp32dev
platform = espressif32
############################
framework = arduino
test_framework = unity