From d84ecb6fb25690f610f449676eb98110c70d7d77 Mon Sep 17 00:00:00 2001 From: FeniksFire Date: Tue, 18 Jul 2017 21:18:37 +0200 Subject: [PATCH] Tests improvement Delete our logger from tests. Make correction. --- .travis.yml | 2 +- test/CVcmiTestConfig.cpp | 4 ---- test/battle/CHealthTest.cpp | 9 ++++----- test/main.cpp | 3 ++- test/map/CMapEditManagerTest.cpp | 17 +++-------------- test/map/CMapFormatTest.cpp | 11 ----------- 6 files changed, 10 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 068aa0c46..3a4668c26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ matrix: compiler: gcc env: VCMI_PLATFORM='linux' REAL_CC=gcc-4.8 REAL_CXX=g++-4.8 PACKAGE=g++-4.8 SUPPORT= - os: linux - env: VCMI_PLATFORM='mxe' MXE_TARGET=i686-w64-mingw32.shared + env: VCMI_PLATFORM='mxe' MXE_TARGET=i686-w64-mingw32.shared VCMI_CMAKE_FLAGS='-DENABLE_TEST=0' sudo: required - os: osx env: VCMI_PLATFORM='mac' diff --git a/test/CVcmiTestConfig.cpp b/test/CVcmiTestConfig.cpp index bb22d4920..63a658200 100644 --- a/test/CVcmiTestConfig.cpp +++ b/test/CVcmiTestConfig.cpp @@ -24,13 +24,9 @@ CVcmiTestConfig::CVcmiTestConfig() { console = new CConsoleHandler(); - CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Test_log.txt", console); - logConfig.configureDefault(); preinitDLL(console); settings.init(); - logConfig.configure(); loadDLLClasses(); - logGlobal->info("Initialized global test setup."); /* TEST_DATA_DIR may be wrong, if yes below test don't run, find your test data folder in your build and change TEST_DATA_DIR for it*/ diff --git a/test/battle/CHealthTest.cpp b/test/battle/CHealthTest.cpp index 9dc4fd81a..f0062291b 100644 --- a/test/battle/CHealthTest.cpp +++ b/test/battle/CHealthTest.cpp @@ -21,9 +21,8 @@ class HealthTest : public ::testing::Test { public: UnitHealthInfoMock mock; - HealthTest() : health(&mock){ - - } + HealthTest() : health(&mock) + {} void setDefaultExpectations() { @@ -229,8 +228,8 @@ TEST_F(HealthTest, singleUnitStack) //one Titan - EXPECT_CALL(mock, unitMaxHealth()).WillRepeatedly(Return(1)); - EXPECT_CALL(mock, unitBaseAmount()).WillRepeatedly(Return(300)); + EXPECT_CALL(mock, unitMaxHealth()).WillRepeatedly(Return(300)); + EXPECT_CALL(mock, unitBaseAmount()).WillRepeatedly(Return(1)); health.init(); diff --git a/test/main.cpp b/test/main.cpp index b1fe2f444..52b7c53ef 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -12,7 +12,8 @@ #include "CVcmiTestConfig.h" #include "../lib/filesystem/CMemoryBuffer.h" -int main(int argc, char ** argv){ +int main(int argc, char ** argv) +{ ::testing::InitGoogleTest(&argc, argv); CVcmiTestConfig test; return RUN_ALL_TESTS(); diff --git a/test/map/CMapEditManagerTest.cpp b/test/map/CMapEditManagerTest.cpp index 3bcff96f4..6583cd819 100644 --- a/test/map/CMapEditManagerTest.cpp +++ b/test/map/CMapEditManagerTest.cpp @@ -22,7 +22,6 @@ TEST(MapManager, DrawTerrain_Type) { - logGlobal->info("CMapEditManager_DrawTerrain_Type start"); try { auto map = make_unique(); @@ -102,23 +101,19 @@ TEST(MapManager, DrawTerrain_Type) } catch(const std::exception & e) { - logGlobal->error("CMapEditManager_DrawTerrain_Type crash"); - logGlobal->error(e.what()); + FAIL()<info("CMapEditManager_DrawTerrain_Type finish"); } TEST(MapManager, DrawTerrain_View) { - logGlobal->info("CMapEditManager_DrawTerrain_View start"); try { const ResourceID testMap("test/TerrainViewTest", EResType::MAP); // Load maps and json config const auto originalMap = CMapService::loadMap(testMap); auto map = CMapService::loadMap(testMap); - logGlobal->info("Loaded test map successfully."); // Validate edit manager auto editManager = map->getEditManager(); @@ -146,10 +141,6 @@ TEST(MapManager, DrawTerrain_View) const auto & posVector = posNode.Vector(); if(posVector.size() != 3) throw std::runtime_error("A position should consist of three values x,y,z. Continue with next position."); int3 pos(posVector[0].Float(), posVector[1].Float(), posVector[2].Float()); -#if 0 - logGlobal->trace("Test pattern '%s' on position x '%d', y '%d', z '%d'.", patternStr, pos.x, pos.y, pos.z); - CTerrainViewPatternUtils::printDebuggingInfoAboutTile(map.get(), pos); -#endif // 0 const auto & originalTile = originalMap->getTile(pos); editManager->getTerrainSelection().selectRange(MapRect(pos, 1, 1)); editManager->drawTerrain(originalTile.terType, &gen); @@ -165,15 +156,13 @@ TEST(MapManager, DrawTerrain_View) } EXPECT_TRUE(isInRange); if(!isInRange) - logGlobal->error("No or invalid pattern found for current position."); + FAIL()<<("No or invalid pattern found for current position."); } } } catch(const std::exception & e) { - logGlobal->info("CMapEditManager_DrawTerrain_View crash"); - logGlobal->info(e.what()); + FAIL()<info("CMapEditManager_DrawTerrain_View finish"); } diff --git a/test/map/CMapFormatTest.cpp b/test/map/CMapFormatTest.cpp index 5c186dde4..d889d2192 100644 --- a/test/map/CMapFormatTest.cpp +++ b/test/map/CMapFormatTest.cpp @@ -26,7 +26,6 @@ static const int TEST_RANDOM_SEED = 1337; TEST(MapFormat, Random) { - logGlobal->info("MapFormat_Random start"); SCOPED_TRACE("MapFormat_Random start"); std::unique_ptr initialMap; @@ -63,9 +62,6 @@ TEST(MapFormat, Random) tmp.write((const char *)serializeBuffer.getBuffer().data(),serializeBuffer.getSize()); tmp.flush(); tmp.close(); - - logGlobal->info("Test map has been saved to:"); - logGlobal->info(path.string()); } SCOPED_TRACE("MapFormat_Random saved"); #endif // 1 @@ -79,7 +75,6 @@ TEST(MapFormat, Random) c(serialized, initialMap); } SCOPED_TRACE("MapFormat_Random finish"); - logGlobal->info("MapFormat_Random finish"); } static JsonNode getFromArchive(CZipLoader & archive, const std::string & archiveFilename) @@ -114,8 +109,6 @@ static void addToArchive(CZipSaver & saver, const JsonNode & data, const std::st TEST(MapFormat, Objects) { - logGlobal->info("MapFormat_Objects start"); - static const std::string MAP_DATA_PATH = "test/ObjectPropertyTest/"; const JsonNode initialHeader(ResourceID(MAP_DATA_PATH+"header.json")); @@ -173,8 +166,6 @@ TEST(MapFormat, Objects) tmp.write((const char *)serializeBuffer.getBuffer().data(),serializeBuffer.getSize()); tmp.flush(); tmp.close(); - - logGlobal->infoStream() << "Test map has been saved to " << path; } { @@ -196,6 +187,4 @@ TEST(MapFormat, Objects) JsonMapComparer c; c.compareTerrain("underground", actualUnderground, expectedUnderground); } - - logGlobal->info("MapFormat_Objects finish"); }