bandit
bandit copied to clipboard
Qt Creator doesn't follow symbol under cursor
I have a problem when editing my test since a few month: when I have more than one test file (with a go_bandit([]{ section each), querying a symbol definition with F2 in a unit test jumps to a go_bandit statement in another file.
Here is a short example:
// pouet.h
class Pouet {
QString _name;
public:
Pouet(QString name) : _name(name) {}
QString name() const {
return _name;
}
};
// test_pouet.cpp
#include "bandit/bandit.h"
#include "pouet.h
using namespace bandit;
using namespace snowhouse;
go_bandit([]() {
it("has a name", [] {
Pouet pouet("martin");
AssertThat(pouet.name(), "martin");
});
});
// test_baba.cpp
#include "bandit/bandit.h"
#include "baba.h
using namespace bandit;
using namespace snowhouse;
go_bandit([]() {
...
});
Here asking the symbol definition of name() at the line 11 of test_pouet.cpp jumps to line 8 of test_baba.cpp instead of line 6 of pouet.h
Qt Creator raises also this warning for both go_bandit statements.
After digging in the code, I replaced go_bandit([]() { by bandit::detail::spec_registrar TestPouet([]() { and bandit::detail::spec_registrar TestBaba([]() { to restore the "jump to definition" feature and suppress the clazy warning.
I know you don't use the Qt framework but I wrote this issue to:
- log my problem if anyone has the same issue
- have your light about using
bandit::detail:spec_registrar TestPouet([]() {instead ofgo_bandit([]() {and in particular the removal of thestaticstatement.
The registration is indeed not very clear to me at this time.
Thanks for your issue. I am currently not sure where to go with the go_bandit macro (see also #164). I have a tendency to deprecate it and replace it by a non-macro solution. Still not sure where to go with it. I currently have no time to work on bandit anyway, but I have time to let that sink in.