Announcement

Collapse
No announcement yet.

How to use GoogleTest properly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Originally posted by Malo88 View Post
    nansP There you go man! I've finally finished it and it works. I've uploaded everything in here:

    https://github.com/malo88/UnrealGoogleTestExample

    Let me know anyway when you have your other repo you mentioned last time. Cheers
    Nice, well done! I will test it soon. Thanks for the quote I appreciate that!

    Leave a comment:


  • replied
    Hi Malo88,

    I was busier than I thought this last weekend, but here they are:
    https://github.com/NansPellicari/UE4-TimelineSystem
    https://github.com/NansPellicari/UE4-FactorsFactory

    They also use depencencies as tests helpers:
    https://github.com/NansPellicari/UE4-TestsHelpers
    https://github.com/NansPellicari/UE4-CoreHelpers

    You can directly jump to the dev docs where i explain how to launch tests:
    For the UE4-TimelineSystem repo:
    https://github.com/NansPellicari/UE4...s.md#5-testing
    For the UE4-FactorsFactory repo:
    https://github.com/NansPellicari/UE4...s.md#6-testing


    Tests implementations:

    As you will see in the previous links, I use GG tests for unit testing my Core module and UE4 automation tests more as functionnal tests for the UE4 module.

    For the UE4-TimelineSystem repo :For the UE4-FactorsFactory repo :Let me know if there is some lacks of clarity or explanations. I will try to fix that quick! Enjoy!

    Leave a comment:


  • replied
    nansP There you go man! I've finally finished it and it works. I've uploaded everything in here:

    https://github.com/malo88/UnrealGoogleTestExample

    Let me know anyway when you have your other repo you mentioned last time. Cheers

    Leave a comment:


  • replied
    Originally posted by nansP View Post
    Ah ok, yeah I think I see, it was hard to me too to not having a full code example of it's tutorial. The architecture details should be clearer having code samples.
    https://ericlemes.com/2018/12/17/uni...n-unreal-pt-3/ If you take a closer look at the chapter "Using your code in your game", he talking about ExampleGame, ExampleGameCore and the ExampleGame.Build.cs. The ExampleGame build is the UE4 module i've talking about above, and this is the module where the AActor is created. This build embeds the "Engine" and the "ExampleGameCore" as dependencies, so it should build correctly and found the AActor class.
    I hope it could help!
    Ah yes, makes sense! ****, I should stop doing this late at night during the week and start doing it on the weekend, maybe it'll make me focus more
    Originally posted by nansP View Post
    Oh and I wonder, if you are ok with that, it could be great to create a github public repository of your implementation of this tuto.
    This way I can take a look if you want and when it is done you can post it to the Eric's page as code sample to helps other people.
    What do you think?
    Yeah, sounds good, it would be very useful for people like me who get stuck easily! I'm going to maybe ask Eric for confirmation and let you know when it's uploaded.

    Thanks!

    Leave a comment:


  • replied
    Oh and I wonder, if you are ok with that, it could be great to create a github public repository of your implementation of this tuto.
    This way I can take a look if you want and when it is done you can post it to the Eric's page as code sample to helps other people.
    What do you think?

    Leave a comment:


  • replied
    Ah ok, yeah I think I see, it was hard to me too to not having a full code example of it's tutorial. The architecture details should be clearer having code samples.
    https://ericlemes.com/2018/12/17/uni...n-unreal-pt-3/ If you take a closer look at the chapter "Using your code in your game", he talking about ExampleGame, ExampleGameCore and the ExampleGame.Build.cs. The ExampleGame build is the UE4 module i've talking about above, and this is the module where the AActor is created. This build embeds the "Engine" and the "ExampleGameCore" as dependencies, so it should build correctly and found the AActor class.
    I hope it could help!
    Last edited by nansP; 06-13-2020, 08:42 PM.

    Leave a comment:


  • replied
    Thanks nansP ! Sure, no worries, take your time I was asking just because I wanted to complete that tutorial but was stuck by the fact that it wasn't compiling saying AActor not found. Since ericlemes is creating UnrealActorAdapter into the ExampleGameCore module and then using AActor in its cop...so I really wondered how the hell was that compiling

    Leave a comment:


  • replied
    Hi Malo88, the thing is you shouldn't use UE4 objects (I mean by that all UObject class derivations) in your *Core plugins.

    As Eric Lemes says in this post: https://ericlemes.com/2018/12/17/uni...n-unreal-pt-3/, you should work with c++ interfaces & adapters (https://refactoring.guru/design-patterns/adapter) or decorators, proxys,... to give UE4 objects to your Core library.
    So you should create 2 plugins (or modules) MyLibCore & MyLibUE4 with 2 differents goals:
    1. Core: creates your full functionnalities, very lightweight and UE4 agnostic
    2. UE4: creates the bridge from your Core lib to the Unreal Engine, by that I mean it extends your lib to create blueprint functionnalities, UE4 project settings, creating lightweight UObject classes which embed your Core objects, etc...
    It is a bit tricky to do, but it allows you to:
    1. stick to a lightweight Core library you can launch very very fast and often
    2. already create an architecture which respects most of the SOLID principles (thanks interfaces :-))
    3. reduce the amount of UE4 Specs or UnitTest which are cool features but too long to launch (in my taste at least :-)) https://docs.unrealengine.com/en-US/...ion/index.html
    4. making your Core lib UE4 agnostic (or at least with the less dependencies you can), in case you want to export you lib in an another engine.

    If you can wait a bit more, I hope tomorow I will finish 2 repos to show you some full examples of these design concepts, I will noticed you here as promised.

    Note: This is for this purpose I've created this template: https://github.com/NansPellicari/UE4-TPL-CppWithTestEnv
    It allows to have 2 series of tests for each lib and you can use the same process to launch tests for each.
    Last edited by nansP; 06-12-2020, 11:35 AM.

    Leave a comment:


  • replied
    nansP a bit offtopic maybe, but were you able to include AActor in your ExampleGameCore module without having "Engine" in Build.cs but only "Core" (I also added "CoreUObject)? Cause in ericleme's guide he's not adding Engine to avoid increasing build times and apparently it works but mine it's not compiling...

    Leave a comment:


  • replied
    nansP that would be great, thanks, please do!

    Leave a comment:


  • replied
    You're Welcome Malo88!
    I'm very glad it's helping you !! Next week I will push 2 new plugins with a bunch of tests in both ( with Unreal and GG tests included). They will be open source so you'll be able to dig in.
    I could noticed you here if you want ?
    Last edited by nansP; 06-02-2020, 07:08 AM.

    Leave a comment:


  • replied
    Thanks nansP your solution worked perfectly! Basically my problem with the guide provided by ericlemes was that it wasn't building properly the solution but with your method https://github.com/NansPellicari/UE4-GoogleTest it worked like a charm.
    Also, great work with reports! That could be extremely useful with continuous integration. Do you have perhaps also some game code with tdd to show? It would be nice to see how someone else is mocking and implementing tdd with Unreal.

    Leave a comment:


  • replied
    Hi Malo88,

    If you prefer a ready made solution, you can take a look at this repo: https://github.com/NansPellicari/UE4-TPL-CppWithTestEnv
    It uses this light thirdparty lib I've created: https://github.com/NansPellicari/UE4-GoogleTest
    Hope it helps !

    Regards,

    Leave a comment:


  • replied
    Herobrine20XX Unfortunately not, still don't understand how to use those libraries directly from the engine.
    But I found these two extremely helpful guides that I think will do the trick:
    https://github.com/NansPellicari/UE4WithGoogle
    https://ericlemes.com/2018/12/13/uni...in-unreal-pt-2
    I'm going to try them as soon as possible, they both require to build your own unreal from source code though.
    Let me know if you have any luck!

    Leave a comment:


  • replied
    Malo88 Did you find how to integrate google test properly? I'm also kinda stuck, and I can't find any documentation on how to use it...

    I'm trying to make this code works:


    Code:
    #pragma once
    #include "GoogleTest/include/gtest/gtest.h"
    
    GTEST_TEST(MyTest, ShouldWork) {
        EXPECT_TRUE(true);
    }
    
    GTEST_TEST(MyTest, ShouldNotWork) {
        EXPECT_TRUE(false);
    }

    Leave a comment:

Working...
X