Skip to content

Commit

Permalink
tests/README.md updated
Browse files Browse the repository at this point in the history
  • Loading branch information
moneroexamples committed Aug 29, 2018
1 parent 3424802 commit 79e207a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 15 deletions.
20 changes: 9 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (NOT MONERO_DIR)
set(MONERO_DIR ~/monero)
endif()

option(BUILD_TEST "Build tests for the project" ON)
option(BUILD_TEST "Build tests for the project" OFF)

message(STATUS MONERO_DIR ": ${MONERO_DIR}")

Expand Down Expand Up @@ -158,18 +158,16 @@ endif()
target_link_libraries(${PROJECT_NAME} ${LIBRARIES})


#set(COVERAGE_EXCLUDES 'ext/*' '${MONERO_DIR}/*')

include_directories(
if (${BUILD_TEST})
include_directories(
${CMAKE_SOURCE_DIR}/ext/googletest/googletest/include
${CMAKE_SOURCE_DIR}/ext/googletest/googlemock/include)

#include_directories(${MONERO_DIR}/tests/core_tests)
endif()

configure_files(${CMAKE_CURRENT_SOURCE_DIR}/sql ${CMAKE_CURRENT_BINARY_DIR}/sql)



enable_testing()
add_subdirectory(ext/googletest)
add_subdirectory(tests)
if (${BUILD_TEST})
enable_testing()
add_subdirectory(ext/googletest)
add_subdirectory(tests)
endif()
3 changes: 2 additions & 1 deletion sql/openmonero.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ SET time_zone = "+00:00";
-- Database: `openmonero`
--

USE openmonero;
CREATE DATABASE IF NOT EXISTS `openmonero` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `openmonero`;

-- --------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion sql/openmonero_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ SET time_zone = "+00:00";
-- Database: `openmonero_test`
--

USE openmonero_test;
CREATE DATABASE IF NOT EXISTS `openmonero_test` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `openmonero_test`;

-- --------------------------------------------------------

Expand Down
61 changes: 59 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
## Testing OpenMonero
## Testing openmonero

Description how to run tests etc.
[Googletest](https://github.com/google/googletest) and
[googlemock](https://github.com/google/googletest/tree/master/googlemock)
frameworks are used for unit testing of openmonero. There is no need
to install them, as they are provided with openmonero.

### MySQL setup

Testing openmonero's operations on MySQL database are performed using
actuall mysql database. For this purpose a testing database with
some pre-populated data is used: `openmonero_test`. Thus before
tests are run, make sure that `openmonero_test` database is initilized
using `openmonero/sql/openmonero_test.sql` file, and `database_test` contains
information on conneting to the test database in
`openmonero/config/config.json`.

### Compile and run openmonero tests

```bash
# go into build folder of openmonero
cd openmonero/build

# indicate that test should be build
cmake .. -DBUILD_TEST=ON

# compile openmonero with tests
make

# run all tests
make test

# the above command will produce summary of test results (shown below).
# for verbouse output, the following command can use
# make test ARGS=-V

# individual tests executables can also be run. they are located in
# openmonero/build/tests

```

Example test output is:

```bash
mwo@arch:build$ make test
Running tests...
Test project /home/mwo/openmonero/build
Start 1: mysql_tests
1/4 Test #1: mysql_tests ...................... Passed 60.64 sec
Start 2: microcore_tests
2/4 Test #2: microcore_tests .................. Passed 1.67 sec
Start 3: bcstatus_tests
3/4 Test #3: bcstatus_tests ................... Passed 25.39 sec
Start 4: txsearch_tests
4/4 Test #4: txsearch_tests ................... Passed 1.04 sec

100% tests passed, 0 tests failed out of 4

Total Test time (real) = 88.79 sec
```

0 comments on commit 79e207a

Please sign in to comment.