You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as of today it seems that the test cases with it() need to execute the harness.AdaperStartAndWait.
Having a real integration with a mock server, the whole startup of the adapter is processed with each it().
In my opinion it would be more helpful to have additional the approach to have the harness.AdaperStartAndWait in the before() and therefore only one adapter start is necessary.
have a look to https://github.com/foxthefox/ioBroker.fritzdect/tree/2.0.0-class
here I start the mock server in before() and in each it() it is necessary to manipulate the adapter settings and start the adapter, before the test cases are processed. Each device has its own it() for checking its correct creation. This is ca. 20 lines in log accompanied by 3000 lines of log for adapter start (per it()).
The log is truncated at approx.13000 lines, so the whole test can not be checked within the web window (only raw).
It works in such a way, but I think it could work like in the testAdapter.js way.
Here the simplified structure as of today:
tests.integration(path.join(__dirname, '..'), {
defineAdditionalTests(getHarness) {
describe('Test creation of devices', () => {
before('start the emulation', () => {
//start mock
});
it('device check 1', () => {
return new Promise(async (resolve) => {
const harness = getHarness();
harness._objects.getObject('system.adapter.fritzdect.0', async (err, obj) => {
obj.native.fritz_ip = 'http://localhost:3333';
await harness._objects.setObjectAsync(obj._id, obj);
// Start the adapter and wait until it has started
await harness.startAdapterAndWait();
harness.states.getState('fritzdect.0.DECT_087610006161.productname', function(err, state) {
if (err) console.error(err);
expect(state).to.exist;
if (!state) {
console.error('state "fritzdect.0.DECT_087610006161.productname" not set');
} else {
console.log('fritzdect.0.DECT_087610006161.productname ... ' + state.val);
}
expect(state.val).to.exist;
expect(state.val).to.be.equal('FRITZ!DECT 200');
});
// and many more states
});
});
});
it('device check 2', () => {
return new Promise(async (resolve) => {
const harness = getHarness();
harness._objects.getObject('system.adapter.fritzdect.0', async (err, obj) => {
obj.native.fritz_ip = 'http://localhost:3333';
await harness._objects.setObjectAsync(obj._id, obj);
// Start the adapter and wait until it has started
await harness.startAdapterAndWait();
harness.states.getState('fritzdect.0.DECT_087610006161.productname', function(err, state) {
if (err) console.error(err);
expect(state).to.exist;
if (!state) {
console.error('state "fritzdect.0.DECT_087610006161.productname" not set');
} else {
console.log('fritzdect.0.DECT_087610006161.productname ... ' + state.val);
}
expect(state.val).to.exist;
expect(state.val).to.be.equal('FRITZ!DECT 200');
});
// and many more states
});
});
});
// next it()
});
};
});
my idea:
tests.integration(path.join(__dirname, '..'), {
defineAdditionalTests(getHarness) {
describe('Test creation of devices', () => {
before('start the emulation', () => {
//start mock
//setup harness
const harness = getHarness();
harness._objects.getObject('system.adapter.fritzdect.0', async (err, obj) => {
obj.native.fritz_ip = 'http://localhost:3333';
await harness._objects.setObjectAsync(obj._id, obj);
});
// Start the adapter and wait until it has started
await harness.startAdapterAndWait();
});
it('device check 1', () => {
return new Promise(async (resolve) => {
harness.states.getState('fritzdect.0.DECT_087610006161.productname', function(err, state) {
//tests
});
// and many more states
});
});
});
it('device check 2', () => {
return new Promise(async (resolve) => {
return new Promise(async (resolve) => {
harness.states.getState('fritzdect.0.DECT_087610006161.productname', function(err, state) {
//tests
});
// and many more states
});
});
});
// next it()
});
};
});
The text was updated successfully, but these errors were encountered:
the idea from above is only to show where I would see the implementation of adapterstartandwait and would see an improvement (but there is no branch or coding for this ).
as of today it seems that the test cases with it() need to execute the harness.AdaperStartAndWait.
Having a real integration with a mock server, the whole startup of the adapter is processed with each it().
In my opinion it would be more helpful to have additional the approach to have the harness.AdaperStartAndWait in the before() and therefore only one adapter start is necessary.
have a look to https://github.com/foxthefox/ioBroker.fritzdect/tree/2.0.0-class
here I start the mock server in before() and in each it() it is necessary to manipulate the adapter settings and start the adapter, before the test cases are processed. Each device has its own it() for checking its correct creation. This is ca. 20 lines in log accompanied by 3000 lines of log for adapter start (per it()).
The log is truncated at approx.13000 lines, so the whole test can not be checked within the web window (only raw).
It works in such a way, but I think it could work like in the testAdapter.js way.
Here the simplified structure as of today:
my idea:
The text was updated successfully, but these errors were encountered: