Comments (3)
Idea / Solution is to implement and use a Qt based WireProtocolServer
in the main of the test applikation:
// initialize qt base wire protocol server
QtWireProtocolHandler wire_protocol_handler( listenHost, port, parser.isSet( "verbose" ) );
// start processung
wire_protocol_handler.process();
// run qt eventloop in main thread
return app.exec();
Implementations (attached as zip)
class QtWireProtocolHandler : public QObject
{
Q_OBJECT
public:
explicit QtWireProtocolHandler( const std::string& host, int port, bool verbose );
~QtWireProtocolHandler() override;
void process();
protected slots:
void onClose();
private:
std::unique_ptr<CukeEngineImpl> cukeEngine = nullptr;
std::unique_ptr<JsonWireMessageCodec> wireCodec = nullptr;
std::unique_ptr<WireProtocolHandler> protocolHandler = nullptr;
std::unique_ptr<SocketServer> server = nullptr;
bool verbose = false;
};
Which uses a custom Implementation of SocketServer
class QtTCPSocketServer : public QObject, public SocketServer
{
Q_OBJECT
public:
typedef unsigned short port_type;
explicit QtTCPSocketServer( const ProtocolHandler* protocolHandler );
void listen( const port_type port );
void listen( const asio::ip::tcp::endpoint endpoint );
asio::ip::tcp::endpoint listenEndpoint() const;
void acceptOnce() override;
signals:
void closed();
private:
void doAcceptOnce( asio::basic_socket_acceptor<asio::ip::tcp>& acceptor );
void timerEvent( QTimerEvent* ) override;
asio::ip::tcp::acceptor acceptor;
std::unique_ptr<AsyncStreamReader> mAsyncStreamReader = nullptr;
asio::ip::tcp::iostream mStream;
};
from cucumber-cpp.
@kreuzberger I strongly recommend to not include the Qt classes nor UI in the acceptance tests. And not timer, you don't want to make your tests slower than needed. Only include and test the business logic of the application. When doing so, you probably don't need the event handling. This removes asynchronous (non-deterministic) behavior, making the tests stable.
I had cases where we had queues (in Qt this would be queued connections) in the code under test. The solution was to dispatch the stuff in the queue until empty after every step. I think it was with QEventLoop::processEvents within AFTER_STEP hook. Or something like here.
from cucumber-cpp.
I agree with most of your doubts. Testing with no such constraints make live easier. Main advantage of the gherkin language is for me still to test user scenarios (not the gui) but if the app under the test is a rich desktop qt app and runs in a multi process enviroment i have to face it. Or use Squish. But testing the logic with squish is much more slower and complicated i think. But this is currently my intention, test the app instead of squish/gherkin with a different (and maybe better) approach.
But back to the questions:
- The existence of a nomain library is for me the hint that this library could be used.
- The names and used classes have an "internal" namespace, but if used as static library i can access them without any problems. The CUCUMBER_CPP_EXPORT is a hint for me that the classes could be used as an API even if builded as shared libraries?
from cucumber-cpp.
Related Issues (20)
- WANTED: A new maintainer 🔧🙋♀️🙋🏾♂️🙋🏼 HOT 24
- Embedded c++ support HOT 9
- Rename master branch to main HOT 1
- Add Conan support for cucumber-cpp HOT 1
- [FEATURE] comparing result of performances (upload data in the report) HOT 2
- sudo cmake --build /home/yizhu/cucumber-cpp/ --target features, this command get errors HOT 1
- Is there a working example of cucumber (c cmake, boost) for c++? HOT 5
- Failed tests when checking implementation against common cucumber test suite HOT 2
- README.md has dead link HOT 1
- request a new release HOT 2
- nlohmann-json I think breaks the installation HOT 2
- cucumber.wire ignored (older versions don't) HOT 2
- Update Conformance / Use u2d versions HOT 4
- Minimal CI for Windows
- Full fledged CI for Windows
- Confusing script name run-all.sh HOT 1
- Getting rid of ruby dependency HOT 6
- QTestDriver Implementation not working on Windows HOT 1
- Compilation and Library Use HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cucumber-cpp.