Skip to content

My first build native test does not success #27

@phunson

Description

@phunson

Today, I just try to use native env. I try to find some complete reference how to create and do this. but does not get any complete step by step. this is what i did from collect information from many web site.

1). I crated "test.cpp" under /project/led/test/ as below. (copy code from some example)

#include <Arduino.h>
#include <unity.h>

void test_get_number_padding() {
TEST_FAIL();
}

void setup() {
Serial.begin(115200);
delay(2000);
UNITY_BEGIN();
RUN_TEST(test_get_number_padding);
UNITY_END();
}

void loop() {}

  1. modify platformio.ini by add below

[env:native_test]
platform = native
test_build_src = yes

  1. run CLI => pio test -e native_test -vvv then I got result as below

PS C:\Users\chaichan\Documents\PlatformIO\Projects\Led> pio test -e native_test
Collected 1 tests (*)

Processing * in native_test environment

Building...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoFake @ 0.4.0 (License: Unknown, Path: C:\Users\chaichan\Documents\PlatformIO\Projects\Led.pio\libdeps\native_test\ArduinoFake)
|-- Unity @ 2.6.0 (License: MIT, Path: C:\Users\chaichan\Documents\PlatformIO\Projects\Led.pio\libdeps\native_test\Unity)
Building in test mode
g++ -o .pio\build\native_test\program.exe .pio\build\native_test\unity_config_build\unity_config.o .pio\build\native_test\test\test.o -L.pio\build\native_test -Wl,--start-group .pio\build\native_test\libb5e\libArduinoFake.a .pio\build\native_test\lib98d\libUnity.a -Wl,--end-group
.pio\build\native_test\lib98d\libUnity.a(unity.o):unity.c:(.text+0x273c): undefined reference to setUp' .pio\build\native_test\lib98d\libUnity.a(unity.o):unity.c:(.text+0x2756): undefined reference to tearDown'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to WinMain@16' collect2.exe: error: ld returned 1 exit status *** [.pio\build\native_test\program.exe] Error 1 Building stage has failed, see errors above. Use pio test -vvv` option to enable verbose output.
------------------------------------------------ native_test:* [ERRORED] Took 2.02 seconds ------------------------------------------------

================================================================= SUMMARY =================================================================
Environment Test Status Duration


uno * SKIPPED
native_test * ERRORED 00:00:02.018
================================================ 1 test cases: 0 succeeded in 00:00:02.018 ================================================
PS C:\Users\chaichan\Documents\PlatformIO\Projects\Led>

*** please give your comment to fix this issue ****

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions