banditcpp / bandit Goto Github PK
View Code? Open in Web Editor NEWHuman-friendly unit testing for C++11
Home Page: https://banditcpp.github.io/bandit/
License: Other
Human-friendly unit testing for C++11
Home Page: https://banditcpp.github.io/bandit/
License: Other
Makes it easier to use bandit together with most continuous integration systems.
Environment: Win8.1 64bit, Visual Studio 2015 Enterprise
Try to build with the latest code in main branch. Got a lot of errors:
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1> Checking Build System
1> CMake does not need to re-run because E:/GitHub/bandit/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because E:/GitHub/bandit/bandit/assertion_frameworks/snowhouse/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: bandit-specs, Configuration: Debug x64 ------
3>------ Skipped Build: Project: bandit-specs_unity, Configuration: Debug x64 ------
3>Project not selected to build for this solution configuration
4>------ Build started: Project: snowhouse-tests, Configuration: Debug x64 ------
5>------ Skipped Build: Project: clean_cotire, Configuration: Debug x64 ------
5>Project not selected to build for this solution configuration
6>------ Skipped Build: Project: all_unity, Configuration: Debug x64 ------
6>Project not selected to build for this solution configuration
2> Building Custom Rule E:/GitHub/bandit/CMakeLists.txt
2> CMake does not need to re-run because E:\GitHub\bandit\CMakeFiles\generate.stamp is up-to-date.
2> Generating Debug/cotire/bandit-specs_CXX_prefix.hxx
4> Building Custom Rule E:/GitHub/bandit/bandit/assertion_frameworks/snowhouse/CMakeLists.txt
4> CMake does not need to re-run because E:\GitHub\bandit\bandit\assertion_frameworks\snowhouse\CMakeFiles\generate.stamp is up-to-date.
2> before_each_after_each.spec.cpp
4>cl : Command line error D8021: invalid numeric argument '/Wfatal-errors'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(21): error C2206: 'swap': typedef cannot be used for function definition
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(35): error C2065: '_Left': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(35): error C2065: '_Right': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(35): error C2206: 'swap': typedef cannot be used for function definition
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(49): error C2206: 'swap': typedef cannot be used for function definition
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(60): error C2065: '_Left': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(60): error C2065: '_Right': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(60): error C2206: '_Swap_adl': typedef cannot be used for function definition
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(140): error C2988: unrecognizable template declaration/definition
2> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(199): note: see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(140): error C2059: syntax error: '('
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(140): error C2091: function returns function
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(140): error C2059: syntax error: ')'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(150): error C2332: 'class': missing tag name
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(150): error C3306: 'std::': unnamed class template is not allowed
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(150): error C2065: '_Other1': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(150): error C2923: 'std::is_convertible': '_Other1' is not a valid template type argument for parameter '_From'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(151): error C2065: '_Other2': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(151): error C2923: 'std::is_convertible': '_Other2' is not a valid template type argument for parameter '_From'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(153): error C2065: '_Other1': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(153): error C2065: '_Other2': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(153): error C2923: 'std::pair': '_Other1' is not a valid template type argument for parameter '_Ty1'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(153): error C2923: 'std::pair': '_Other2' is not a valid template type argument for parameter '_Ty2'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(154): error C2065: '_Other1': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(154): warning C4346: 'std::integral_constant<_Ty,_Val>::value': dependent name is not a type
2> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(154): note: prefix with 'typename' to indicate a type
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(154): error C2059: syntax error: '>'
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(154): error C2065: '_Other2': undeclared identifier
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(156): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
2>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility(17): fatal error C1075: the left brace '{' was unmatched at the end of the file
7>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------
7>Project not selected to build for this solution configuration
========== Build: 1 succeeded, 2 failed, 0 up-to-date, 4 skipped ==========
I have a test suite consisting of a number of tests, some of which include blocking operations that run for as long as 250ms, but the xunit reporter reports a time
value of 0
for each test.
I'm seeing the same behavior on Windows 7 and RHEL 6.7
The current version makes the compiler crash.
Hopefully wrapping the function variable in a normal class will fix this.
Reported by @bcachet
I like Cedar's matcher syntax, so I've started integrating it into bandit. It's turning out to be rather straightforward to do, but it's also a large pile of work. So, I thought I'd check that I'm working on something that's desirable.
Cedar's matchers allow for assertions with a more readable, and RSpec-like, syntax. They look something like this:
5 must equal(5);
4 must_not equal(5);
5 must be_greater_than(4);
I've pushed a WIP branch to my fork so you can see where I am and what the changes are.
Any thoughts? Problems?
Hi,
It seems that snowhouse is not bundled with bandit in the v2.0.0 download (I only tried the .tar.gz file). I'm guessing it has something to do with snowhouse being a submodule.
This predicably leads to errors when including bandit.h
.
Perhaps it some release scripts (or some such) need updating?
I've started looking into adding support for focusing test examples, and it looks like it will require architectural changes. Or, at least, some refactoring. Before I start on all of that, I'd like to make sure that I'm on the right track, and that such large-scale changes are acceptable.
My current plan is to change the Context object to keep a list of 'normal' examples as well as a list of focused examples. The 'it' handlers will then need to register their closures with the Context instead of running them immediately. The top-level runner would walk the list of Contexts looking for examples to run. If a Context has focused examples, only those are run. Otherwise, it runs the list of normal examples. The before_each and after_each closures would only be run if a Context has any examples to run.
Am I doing this right?
Hi,
Any chance of a new release sometime in the near(ish) future? The auto_ptr warnings issue is rather annoying and I'd prefer to use a "release version" rather than a snapshot, if possible. :)
When compiling bandit using gcc 4.8 and cmake 2.8.7, the variable CMAKE_CXX_COMPILER_VERSION
has no value and so -std=c++0x
is used incorrectly instead of -std=c++11
.
The condition reads as follows (link):
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
endif()
The reason this doesn't work is because the variable CMAKE_CXX_COMPILER_VERSION
was introduced in CMake 2.8.8. Compare the CMake notes:
The minimum version of CMake required by bandit is 2.8.
There are two potential solutions:
execute_process
command to get the gcc version as proposed by this Stack Overflow answer. The revised condition would look like this: if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if(GCC_VERSION VERSION_LESS "4.7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
endif()
A further step would be to use the CMAKE_CXX_COMPILER_VERSION
variable if available, and fall back to the above method if unavailable.
The same problem occurs in Snowhouse. Let me know which is better and I'll prepare a pull request with the fix in both projects.
Trying Bandit/Snowhouse for the first time so this could be my fault? I'm using Qt Creator + Clang but...
struct Test {
void test() {
throw std::runtime_error("fail");
}
};
go_bandit([](){
describe("exception test", [](){
Test test;
it("should fail", [&](){
AssertThrows(std::runtime_error, test.test());
AssertThat(LastException<std::runtime_error>().what(), Is().Containing("fail"));
});
});
});
.../bandit/assertion_frameworks/snowhouse/snowhouse/constraints/containsconstraint.h:22: error: member reference base type 'const char *const' is not a structure or union
return std::find(container.begin(), container.end(), expected) != container.end();
~~~~~~~~~^~~~~~
.../bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h:18: expanded from macro 'AssertThat'
SNOWHOUSE_ASSERT_THAT((p1), (p2), ::snowhouse::DefaultFailureHandler);
^
.../bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h:13: expanded from macro 'SNOWHOUSE_ASSERT_THAT'
::snowhouse::ConfigurableAssert<FAILURE_HANDLER>::That((p1), (p2), FILE, LINE);
^
namespace snowhouse {
template <typename ContainerType>
struct find_in_container_traits
{
template <typename ExpectedType>
static bool find(const ContainerType& container, const ExpectedType& expected)
{
*** return std::find(container.begin(), container.end(), expected) != container.end();
}
};
Hi,
for easier filtering (using --only
or --skip
) it would be awesome if bandit could output a list of the whole describe()
hierarchy. (I'd suggest --list
for such a feature.)
Maybe, sometimes it is also convenient to get a full list of all describe()
and it()
. (--full-list
or --list-them
or --list-all
?)
Thank you,
Stephan
Currently the project doesn't compile with -Wshadow but it should, I think. Can you build it with that flag and fix the errors that crop up?
Good for editor output
In "bandit/reporters/colorizer.h" you include windows.h, but you do so in your namespace.
Therefore if I include windows.h after bandit.h it doesn't because of the #ifdef in the beginning and I don't have windows.h in global namespace.
You use cotire and snowhouse and maybe other things that should rather be in git submodules instead to make it easier to track and update them.
clang++ --version
Ubuntu clang version 3.4-1~exp1 (branches/release_34) (based on LLVM 3.4)
CMAKE_CXX_FLAGS=-stdlib=libc++
-- cotire 1.4.1 loaded.
-- Configuring done
-- Generating done
-- Build files have been written to: /build/clang_bandit
[ 5%] Building CXX object CMakeFiles/bandit-specs.dir/specs/main.cpp.o
In file included from /bandit/specs/main.cpp:1:
In file included from /build/clang_bandit/cotire/bandit-specs_CXX_prefix.hxx:4:
In file included from /bandit/specs/specs.h:4:
In file included from /bandit/bandit/bandit.h:5:
In file included from /usr/include/c++/v1/functional:465:
In file included from /usr/include/c++/v1/memory:599:
/usr/include/c++/v1/tuple:320:11: fatal error: rvalue reference to type '<lambda at /bandit/bandit/grammar.h:111:42>' cannot bind to lvalue of type
'<lambda at /bandit/bandit/grammar.h:111:42>'
: value(__t.get())
^ ~~~~~~~~~
/usr/include/c++/v1/tuple:444:8: note: in instantiation of member function 'std::__1::__tuple_leaf<0, <lambda at /bandit/bandit/grammar.h:111:42> &&, false>::__tuple_leaf' requested here
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
^
/usr/include/c++/v1/functional:1278:26: note: in instantiation of member function 'std::__1::__function::__func<<lambda at /bandit/bandit/grammar.h:111:42>, std::__1::allocator<<lambda at
/bandit/bandit/grammar.h:111:42> >, void ()>::__func' requested here
::new (__f_) _FF(_VSTD::move(__f));
^
/bandit/bandit/grammar.h:111:42: note: in instantiation of function template specialization 'std::__1::function<void ()>::function<<lambda at /bandit/bandit/grammar.h:111:42> >' requested
here
assertion_adapter.adapt_exceptions([&](){
Hello,
Maybe it can be usefull to have some Continuous Integration using some tools like Travis.
An example of .travis.yml file can be:
language: cpp
compiler:
- gcc
- clang
before_script:
- BUILD_DIR=`pwd`/build
- mkdir -p ${BUILD_DIR}
- cd ${BUILD_DIR}
- cmake ..
script:
- cd ${BUILD_DIR}
- make
This configuration file will perform two builds, one using GCC (currently 4.6) and another using Clang (3.2)
This way, we ensure that we don't miss a failing commit and we document how to play with bandit.
Bandit generates xunit output like so:
<?xml version="1.0" encoding="utf-8"?>
<testsuite name="bandit" tests="4" errors="0" failures="0">
<testcase classname="Something" name="does something" time="0">
</testcase>
</testsuite>
...but (at least some) CI publishers expect a time value for the suite, and decimal/float values instead of integers (probably due to schemas like so). Should be:
<?xml version="1.0" encoding="utf-8"?>
<testsuite name="bandit" tests="4" errors="0" failures="0" time="0.0">
<testcase classname="Something" name="does something" time="0.0">
</testcase>
</testsuite>
If you run the following code in valgrind, it reports two memory leaks.
#include <bandit/bandit.h>
#include <exception>
using namespace bandit;
go_bandit([]() {
describe("foo", []() {
it("bar", []() {
AssertThrows(std::exception, throw std::exception());
});
});
});
int main(int argc, char* argv[])
{
return bandit::run(argc, argv);
}
I used gcc 5.4.0, valgrind 3.11.0, bandit at 7b28220 and my call was valgrind --leak-check=full --show-leak-kinds=all ./<testProgram>
Edit: With Apple LLVM version 7.3.0 (clang-703.0.29) for x86_64-apple-darwin15.5.0 there was the same memory leak.
Edit2: w/o the AssertThrows
line, there is still a memory leak. But now it's only one instead of two.
When running cmake on Bandit, a warning is generated stating that the snowhouse-tests target is unknown:
CMake Warning (dev) at CMakeLists.txt:52 (add_custom_command):
Policy CMP0040 is not set: The target in the TARGET signature of
add_custom_command() must exist. Run "cmake --help-policy CMP0040" for
policy details. Use the cmake_policy command to set the policy and
suppress this warning.
The target name "snowhouse-tests" is unknown in this context.
This warning is for project developers. Use -Wno-dev to suppress it.
This is because add_custom_command does not work for targets in subdirectories.
One option is to add the snowhouse-tests to the bandit-specs target, but I don't think this is necessary as they get executed just because of the add_subdirectory. A better choice might be to just remove it.
Add command line option: --only="substring for describes and its to run"
const char* have ownership issues and they will most certainly break if you don't use static messages.
An assertion that a value equals nullptr (AssertThat(some_pointer, Equals(nullptr));
) results in the following compile error:
/bandit/assertion_frameworks/snowhouse/snowhouse/stringize.h:46:56: Use of overloaded operator '<<' is ambiguous (with operand types 'ostream' (aka 'basic_ostream<char>') and 'const nullptr_t')
Is there a better way to make this assertion?
Namespace bandit has "using namespace std".
I'd like to be able to do "using namespace bandit" in my unit tests as per the examples, but still expect my tests to not compile when I make the rookie error of omitting 'std::' somewhere in the headers of the code I'm testing.
It would be nice to get proper TeamCity integration for bandit. I think that the easiest way to accomplish this would be to implement a teamcity reporter that uses tests service messages to output its results..
I am not familiar with testing integration with TC, but if you need to setup a whole server for this, I have a few build config left on my licence. I could configure an automatic build for a branch of bandit and give you full access on it so that you can test the reporter.
There are at least two cases where bandit uses defaulted move constructors, which are not supported by Visual Studio 2013. Can bandit be revised to provide an implementation for these constructors?
In assertion_exception.h
(line 21):
//
// To make gcc < 4.7 happy.
//
assertion_exception(const assertion_exception&) = default;
assertion_exception(assertion_exception&&) = default;
virtual ~assertion_exception() noexcept
{}
In run_policy.h
(line 10):
struct run_policy
{
run_policy() : encountered_failure_(false) {}
run_policy(const run_policy& other) = default;
run_policy(run_policy&&) = default;
virtual ~run_policy() {}
// ...
The function names don't have any semantic value - it's impossible to know what they mean from the name.
describe(description)
describe what?
should be:
setup(description)
it(description)
it ...what???
should be:
test(description)
before_each()
each what?
should be:
before_test()
go_bandit()
where does the bandit go to?
I assume you like this sort of naming style, so my suggestion is adding aliases for the functions with proper semantics so other people could use it.
When using in Visual Studio 2012 it reports warnings and memory leaks.
Warnings (in german, sorry):
bandit/external/optionparser.h(416): warning C4510: 'option::Descriptor': Standardkonstruktor konnte nicht generiert werden (..\..\ds4b-tests-db\src\main.cpp)
bandit/external/optionparser.h(309): Siehe Deklaration von 'option::Descriptor'
bandit/external/optionparser.h(416): warning C4610: 'struct 'option::Descriptor' kann nicht instanziiert werden - benutzerdefinierter Konstruktor erforderlich (..\..\ds4b-tests-db\src\main.cpp)
bandit/options.h(23): warning C4800: 'const option::Option *': Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten möglich) (..\..\ds4b-tests-db\src\main.cpp)
bandit/options.h(33): warning C4800: 'const option::Option *': Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten möglich) (..\..\ds4b-tests-db\src\main.cpp)
bandit/options.h(43): warning C4800: 'const option::Option *': Variable wird auf booleschen Wert ('True' oder 'False') gesetzt (Auswirkungen auf Leistungsverhalten möglich) (..\..\ds4b-tests-db\src\main.cpp)
bandit/reporters/colorizer.h(54): warning C4244: 'Argument': Konvertierung von 'int' in 'bandit::detail::WORD', möglicher Datenverlust (..\..\ds4b-tests-db\src\main.cpp)
bandit\external\optionparser.h(1617): warning C4701: Die möglicherweise nicht initialisierte lokale Variable "idx" wurde verwendet.
bandit\external\optionparser.h(1630): warning C4701: Die möglicherweise nicht initialisierte lokale Variable "optarg" wurde verwendet.
bandit\external\optionparser.h(1630): warning C4703: Die möglicherweise nicht initialisierte lokale Zeigervariable 'optarg' wurde verwendet.
memory leaks:
4> Detected memory leaks!
4> Dumping objects ->
4> {81346} normal block at 0x00000000021B9620, 16 bytes long.
4> Data: <P T > 50 A6 54 00 00 00 00 00 00 00 00 00 00 00 00 00
4> {81345} normal block at 0x00000000021B95D0, 16 bytes long.
4> Data: <( T > 28 A6 54 00 00 00 00 00 00 00 00 00 00 00 00 00
4> {81343} normal block at 0x00000000021BA6B0, 16 bytes long.
4> Data: < N > 80 EB 4E 00 00 00 00 00 00 00 00 00 00 00 00 00
4> {81342} normal block at 0x0000000002193FF0, 56 bytes long.
4> Data: < ? ? > F0 3F 19 02 00 00 00 00 F0 3F 19 02 00 00 00 00
4> {81341} normal block at 0x00000000021BAA20, 16 bytes long.
4> Data: <h N > 68 EB 4E 00 00 00 00 00 00 00 00 00 00 00 00 00
4> {81340} normal block at 0x0000000002194770, 56 bytes long.
4> Data: <pG pG > 70 47 19 02 00 00 00 00 70 47 19 02 00 00 00 00
4> {81339} normal block at 0x00000000021B9170, 16 bytes long.
4> Data: <P N > 50 EB 4E 00 00 00 00 00 00 00 00 00 00 00 00 00
4> {81338} normal block at 0x0000000002194570, 56 bytes long.
4> Data: <pE pE > 70 45 19 02 00 00 00 00 70 45 19 02 00 00 00 00
4> Object dump complete.
in reporters/colorizer.h 5:0
could you please add
To make it easy to keep the documentation up-to-date, it would be better if it would be kept on the master branch and copied to gh-pages on each release.
Running clang++
on the following code with -Weverything
(on Mac OSX)
#include <bandit/bandit.h>
int main(int argc, char* argv[]) {
return bandit::run(argc, argv);
}
generates 104 warnings.
The warnings are generated with the following flags.
-Wc++98-compat-local-type-template-args
-Wc++98-compat-pedantic
-Wc++98-compat
-Wdeprecated
-Wdocumentation-unknown-command
-Wdocumentation
-Wexit-time-destructors
-Wheader-hygiene
-Wmissing-noreturn
-Wnon-virtual-dtor
-Wpadded
-Wsign-conversion
-Wweak-vtables
Can you take a look and see if any are worth fixing? I'm not sure if any of them are.
Add:
Sometimes it would be nice to catch exceptions thrown during tests directly with a debugger.
Since bandit catches all exceptions (which is a good thing to have as default) this is currently not possible.
I'd like to have a flag that switches the catching off.
I'm compiling bandit up with VS 2013, on an insanely high end box.
When it compiles as x86, it takes ~5 minutes to build.
When it compiles as x64 it takes ~1 minutes to build (and most of that is linking)
And I had to turn on /bigobj on the compiler.
Is this something weird with VC, or is compiling this stuff just really hard on the compiler?
I'd like to have a reporter that prints the entire test-case's name, i.e. all describe titles that the test-case is nested in, when executing any test-case. Using such a reporter, one is able to easily identify the current test-case upon encountering a crash without looking through the whole test log.
as the title says, the IsNull() method remains undefined, making tests for nullptr impossible.
A similar issue to snowhouse's noexcept use happens in the matcherexception.h file in bandit preventing the code to build under MSVC.
Make it possible to specify that Visual Studio's way of reporting location of assertion failure should be used.
This way Visual Studio developers can locate failing tests more easily.
It would be convenient to be able to use both --skip
and --only
simultaneously or even provide a regex that test titles have to match. It would also be nice to match titles composed of multiple nested describe
names.
Request: Move bandit/bandit
to bandit/include/bandit
. Now when including bandit
(-Iparent/bandit
) other folders (such as bandit/cmake
) are also reachable. If including bandit/include
(-Iparent/bandit/include/
) it only reaches bandit/include/bandit
.
When adding Bandit as a subdirectory in a parent CMake project, I want the option of preventing the tests being built. It increases compile time when building from scratch, but mostly I just like options.
Hi,
for huge test suites it is nice to have a feature like --break-on-failure that leads bandit to exit (i.e., ignore further it()
s and describe()
s and just prints the summary).
Bandit specs are not compiling with VS2012 because of variadic template usage.
As indicated on MSDN C++11 Features Support, variadic templates are not implemented yet.
Here is the output I got:
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1> Checking Build System
1> CMake does not need to re-run because C:/Users/bca/Desktop/Perso/bandit/build/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: bandit-specs, Configuration: Debug Win32 ------
2> Building Custom Rule C:/Users/bca/Desktop/Perso/bandit/CMakeLists.txt
2> CMake does not need to re-run because C:\Users\bca\Desktop\Perso\bandit\build\CMakeFiles\generate.stamp is up-to-date.
2> before_each_after_each.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> context.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> describe.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> fuzzbox.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> it.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> main.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> options.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> run.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> synopsis.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> dots_reporter.spec.cpp
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(23): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\bandit/options.h(33): warning C4800: 'option::Option *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(34): error C2143: syntax error : missing ',' before '...'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/logging_fake.h(35): error C2061: syntax error : identifier 'Args'
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(24): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(29): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(34): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(39): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(44): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(49): error C2660: 'bandit::specs::logging_fake::log' : function does not take 5 arguments
2>C:\Users\bca\Desktop\Perso\bandit\specs/fakes/fake_reporter.h(54): warning C4800: 'const char *' : forcing value to bool 'true' or 'false' (performance warning)
2> Generating Code...
3>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32 ------
3>Project not selected to build for this solution configuration
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========
Does it seem useful to have a timeout option on tests? For example, a third parameter to it
:
it("should do something", [&](){
AssertThat(something, IsTrue());
}, 10);
where this indicates a timeout of 10 seconds (or whatever). By default, there could be no timeout, or a user can set a default timeout via a command line parameter.
I'm imagining a use case where bandit is part of CI tests, and we don't want infinite looping tests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.