linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 83 forks source link

Best approach to make integration tests... #331

Closed peterheard01 closed 9 years ago

peterheard01 commented 9 years ago

Hi Guys,

Didn't know if there was an easy way with lineman to do something like...

"lineman-spec-integration"

To just run integration tests from jasmine that will do IO like http calls and $resource use etc. Maybe the list of integration tests could be specified in the application config or something?

I actually want to exercise my core domain models against their real world api.

Any ideas? I am happy to make something as we need I need it on a project.

Pete

searls commented 9 years ago

I wrote lineman-spec-browser for this purpose. It's not widely used but might be a good start.

peterheard01 commented 9 years ago

Hi, After trying all day to get two unit test files to be created specs-uni.js and specs.integration.js I went back to square one and installed the stock lineman template and then tried to install your lineman spec browser and I got this....

CXX(target) Release/obj.target/nodejavabridge_bindings/src/java.o In file included from ../src/java.cpp:2: ../src/java.h:7:10: fatal error: 'jni.h' file not found

include

     ^

1 error generated. make: *\ [Release/obj.target/nodejavabridge_bindings/src/java.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12) gyp ERR! System Darwin 14.0.0 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /stuff/petedl/lineman-master/node_modules/lineman-spec-browser/node_modules/webdriver-sync/node_modules/java gyp ERR! node -v v0.10.33 gyp ERR! node-gyp -v v1.0.1 gyp ERR! not ok

npm ERR! java@0.3.3 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the java@0.3.3 install script. npm ERR! This is most likely a problem with the java package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls java npm ERR! There is likely additional logging output above. npm ERR! System Darwin 14.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "lineman-spec-browser" "--save-dev" npm ERR! cwd /stuff/petedl/lineman-master npm ERR! node -v v0.10.33

So I reinstalled Java and then I ran...

npm install -g node-gyp

But still no luck.

I'm really struggling to try and figure out how to get lineman to just create a suite of integration tests that we can run with a different command and keep in a different folder we need it for a project I am on. Is there any deep technical info on lineman so I can figure out how the whole thing is wired up?

searls commented 9 years ago

The reason Lineman doesn't have better support for this is because we typically integration test in the host language of the server side. So, for instance, if we're building a Lineman front-end app with a Ruby API service behind it, we'll write our integration suite with the two running simultaneously in Ruby with Capybara.

searls commented 9 years ago

So I'd sooner recommend building a test suite in some well-worn integration testing tool and then in a beforeAll starting lineman run in a child process and pointing your tests at it

peterheard01 commented 9 years ago

I see what you are saying. Unfortunately in this scenario we have been brought in to create a fat client to fit over the top of their infrastructure. So we are just js devs fitting a new app over legacy stuff. Their infra. is very leaky and fragile and to be able to just run...

lineman spec-int

And know immediately where our integration with their systems is failing puts us in a very good position. They know they have problems we need to be able to tell them. With regards to writing tests in ruby or .net or whatever just seems such a duplication of effort. I have a module called 'reservationmaker' which is totally unit tested in jasmine. I just want to remove my stubs and fire it off every hour if I need even locally when I need because the project is so fragile etc, anyway I'm blathering on. Maybe I will have to just make a separate project or something and use testem, who knows, my brain hurts after today :-\

searls commented 9 years ago

In that case I'd still either use a separate,more robust tool to test (shelling to lineman run), or I'd struggle to figure out why Java is angry in lineman-spec-browser. 

Sorry I don't have more for you :(

On Fri, Nov 7, 2014 at 3:15 PM, Pete Heard notifications@github.com wrote:

I see what you are saying. Unfortunately in this scenario we have been brought in to create a fat client to fit over the top of their infrastructure. So we are just js devs fitting a new app over legacy stuff. Their infra. is very leaky and fragile and to be able to just run... lineman spec-int

And know immediately where our integration with their systems is failing puts us in a very good position. They know they have problems we need to be able to tell them. With regards to writing tests in ruby or .net or whatever just seems such a duplication of effort. I have a module called 'reservationmaker' which is totally unit tested in jasmine. I just want to remove my stubs and fire it off every hour if I need even locally when I need because the project is so fragile etc, anyway I'm blathering on. Maybe I will have to just make a separate project or something and use testem, who knows, my brain hurts after today :-\

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman/issues/331#issuecomment-62205188

peterheard01 commented 9 years ago

Yes thanks for all your help so far anyway....

peterheard01 commented 9 years ago

oh but can I just ask what these funny symbols mean and where they end up being used?

files: ["<%= files.js.concatenated %>", "<%= files.js.concatenatedSpec %>"]

This is what has been confusing me the most today :-) Is it a coffescript tag? because when I pump that symbol into google I get nothing....

searls commented 9 years ago

Yup, those are interpolated by grunt. They are defined in config/files.js (or files.coffee if they reference values specified in lineman core

On Fri, Nov 7, 2014 at 4:27 PM, Pete Heard notifications@github.com wrote:

oh but can I just ask what these funny symbols mean and where they end up being used?

files: ["<%= files.js.concatenated %>", "<%= files.js.concatenatedSpec %>"]

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman/issues/331#issuecomment-62215343

peterheard01 commented 9 years ago

Ah ha I see, thanks...

peterheard01 commented 9 years ago

And sorry one more which really got me....

{process.cwd()}

Is that coffeescript? The funny chars?

searls commented 9 years ago

CoffeeScript features string interpolation. Which means anything between #{} in a double-quoted string will be evaluated.

On Fri, Nov 7, 2014 at 4:45 PM, Pete Heard notifications@github.com wrote:

And sorry one more which really got me....

{process.cwd()}

Is that coffeescript? The funny chars?

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman/issues/331#issuecomment-62219974

peterheard01 commented 9 years ago

ok I see I see I think I will do some more learning about Grunt etc I am just looking through the code now to see how you guys put it together I am sure I will have it soon! :-) thanks