-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor internal architecture of Alsatian #474
Comments
The most notable improvement is used in the example. Notice in the below extract, that the 2 Testcases and their individual expectations are run asynchronously. Code runner.addTest(
new TestCase(() => {
Expect(
new Promise((resolve, reject) => {
setTimeout(() => {
reject();
}, 100);
})
).toResolve('reject after 100 milliseconds should resolve'); // Fail
Expect(
new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 20);
})
).toResolve('resolve after 20 milliseconds should resolve'); // Pass
})
);
runner.addTest(
new TestCase(() => {
Expect(
new Promise((resolve, reject) => {
setTimeout(() => {
reject();
}, 10);
})
).toResolve('reject after 10 milliseconds should resolve'); // Fail
Expect(
new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 2);
})
).toResolve('resolve after 2 milliseconds should resolve'); // Pass
})
); Output Passed: Expected [object Promise] ToResolve undefined.Description: resolve after 2 milliseconds should resolve
Failed: Expected [object Promise] ToResolve undefined.Description: reject after 10 milliseconds should resolve
Passed: Expected [object Promise] ToResolve undefined.Description: resolve after 20 milliseconds should resolve
Failed: Expected [object Promise] ToResolve undefined.Description: reject after 100 milliseconds should resolve |
Hey @pathurs, I'm not sure I quite understand this proposal. Is this a proposal to replace the way in which you write tests? i.e. a replacement for: import { TestFixture, TestCase, Expect } from "alsatian";
@TestFixture("fixture")
export class NewTests {
@TestCase(2)
@TestCase(3)
@TestCase(0)
public testFunction(notOne: number) {
Expect(1).not.toEqual(notOne);
}
} If so what's the reason for such a change and what benefits do you foresee? :) |
I've updated the original comment, hopefully it makes more sense. |
Indeed it does! Thanks for the clarification. I think for this is a great idea to try and coalesce all the new features we need into an architectural plan. There may be a few other considerations which may shape the architecture as well. Let me have a ponder and I'll add some more back here then we can get making it even more awesome!! :) |
My thoughts so far Async as default
Expect reworkPOC example to follow
TAP compatibility
Considerations
|
Async as default makes a ton of sense. Having to discern between the two seems awkward and error-prone. |
I've created a Proof of Concept (POC) here:
https://github.com/pathurs/alsatian-refactor-POC
This would be an internal refactor of Alsatian's main processing stream, and would hopefully be able to solve many of the issues.
Improvements over current Alsatian architecture:
and related to #455 #436
My code was made in only a few hours, so it does not match the same API with decorators, however I hope you can imagine it would work the same way, but with improved handling.
@jamesadarich @Jameskmonger fyi
The text was updated successfully, but these errors were encountered: