Closed facundocabrera closed 11 years ago
Cool!
Now, we will need to try something extra:
Regarding Jasmine/qUnit, I think it's sounds like a lot. Chai extended with sinon features should be enough for asserts, isn't it?
On the other hand, Testacular seems great to add some real cross browser testing.
If it's ok with you, I will update the tests-suite's branch home page with the docs.
Because the evaluation we did in #2 we have some facts:
Maybe the generator's test suite could be a good example for a future generalization of the testing process.
What do you think?
After evaluating for a while, we want to create a brand new generator (new repository maybe).
It will handle the creation of tests. We think it's better because we will have everything in just one piece that could be use to test any generator and every project. Just install inside your project and use it!
First of all, we need to create (inside our project) a structure.json file in this way (see #### Commands for more information):
{
"test": {
"stories": {
},
"tests": {
},
"reports": {
},
"automation": {
},
"live": {
}
},
"your-project-name": {
"file1": "lala/js/bla",
"file2": "lala/css/bla",
"file3": "lala/images/bla",
}
}
After we have the basic structure, we will write every single .story file using the BDD principles like we said in https://github.com/dendril/generator-deloitte/issues/2
Note: The automation folder is new (probably a future headache for programmers) but it will add a high metric quality to any project. It will use phantomjs with Jasmine for this. The live folder will contain every BDD story for real time check. eg.g check that a text input is visible after complete a previous one.
' yo dt-pcg
- It will look for all .story files and matching them with the new .js files creating the basic Jasmine skeleton.
We propose this skeleton (Please validate it)
describe("Scenario <NAME>", function() {
it("GVIEN ...", function() {
// Write test here
});
it("WHEN ...", function() {
// Write test here
});
it("THEN ...", function() {
// Write test here
});
it("AND ...", function() {
- It's important to clarify that this will build the tests and check for your generator's file structure every time it runs.
- Note: If the .js files were modified and you re-run the generator, it will run just the tests. It's intelligent!
We could provide an API for everybody who wants to write his own method for testing theirs generators. Every time you run yo dt-pcg you will be running that brand new method if needed.
Just go ahead and let see what you can get :smile:
Vamos a tener una carpeta live, donde van a estar los .story del SMOKE TEST y la carpeta automation donde van a estar los .js. Todo esto lo automatizamos con grunt y la idea es generar los .js (tests) con un comando de grunt. Aca va una exlicacion, que les parece?
Scenario: We need to see a text that confirms that the user was valid
Given a
Examples page_url|user_name|text_area|text_information|label_area|time http://www.test-url.com|test-user|#text-area-id|the user is valid|#label-id-test|2000
De aca sacamos que podemos usar
exports.tests = [{
name: "checks if title contains the search query",
func: function(done) {
var page_url = 'http://www.test-url.com',
user_name = 'test-user',
text_area = '#text-area-id',
text_information = 'the user is valid',
label_area = '#label-id-test';
exports.driver
.click('#js-command-bar-field')
.setValue('#js-command-bar-field',query)
.submitForm('.command-bar-form')
.getTitle(function(title) {
buster.assertions.assert(title.indexOf(query) !== -1);
})
.end(done);
}}
];
Test suite quick start (?
Added a new branch called tests-unit for developing a test suite for this brand new generator.
Inside the cloned folder should run:
npm install -g generator-mocha
yo mocha
It will create a new test folder and inside of it the structure:
Now should be able to write some tests using Mocha:
http://visionmedia.github.io/mocha
e.g:
Assertions
npm install sinon-chai
Usage:
http://chaijs.com/plugins/sinon-chai
Let me know what you think.