Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

12-28-2014 , 08:16 PM
If that's all that func does I see no reason to test it
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-28-2014 , 09:14 PM
Since we're talking testing, I have a question too

To what extent do you go to fix tests after making a change that breaks a ton of tests? I wrote a tool that gives a range breakdown (like flopzilla) for holdem hands. I made some changes so one of the main objects get instantiated with a string representing the board "AcKd4d" instead of a hash representing the board. This broke a ton of tests I had written and I don't feel like changing it... I just had the thought now of accepting both hashes and strings but the question remains.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-28-2014 , 10:42 PM
If you don't fix the tests they are worthless. Going live with broken tests means you won't know if the next bit of code works or is failing an already broken test.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-28-2014 , 11:13 PM
Quote:
Originally Posted by kerowo
If you don't fix the tests they are worthless. Going live with broken tests means you won't know if the next bit of code works or is failing an already broken test.
+1, also having such fragile tests may indicate other problems with the design (not necessarily, but maybe)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-28-2014 , 11:33 PM
Quote:
Originally Posted by suzzer99
Glob is a 3rd party module which is looking at the actual file system. How could I mock something like that?
"Don't mock what you don't own"

http://www.mockobjects.com/2007/04/t...is-mocked.html

If applicable, you can write a thin wrapper over the 3rd party module, which delegates to the 3rd party module, and mock your wrapper. Otherwise don't mock and do an integration test instead.

Quote:
Also initNodule is an internal method that is not exposed by the component. Is there any way to fake/spoof/spy on that?
you should never be writing tests for internal methods. if you find that you need to, or want to, it means something is wrong with your design. if it's truly "internal," then you should be testing it implicitly via the public methods that use it. if it's not truly internal, pull it out into its own class/function/module/blah or make it public, and test that. (EDIT: i should clarify here that this isn't free license to make all privates methods public. that's a design decision and shouldn't be influenced by your struggling with tests. that is, the testability should be giving you hints about the design. you shouldn't be bending your design thoughtlessly to achieve testability)


Quote:
Devs with lots of unit-test experience - to what level will you go to make your code more test-friendly if it means convoluting the code? Is this something you wouldn't even bother writing a test for because it's so low level and hard to mock/spy on?
i'll got to great lengths to make the code more testable, but not by convoluting my code. the test friendliness should be making the code simpler. if it's not, you have a problem.

Last edited by gaming_mouse; 12-28-2014 at 11:39 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 06:32 AM
All,

It is my belief that everyone in the world, especially everyone in the world of IT, should watch this Chaos Communication Congress talk by Jacob Appelbaum and Laura Poitras, and read this new publication on an Edward Snowden document.

http://www.spiegel.de/international/...a-1010361.html
http://www.spiegel.de/media/media-35535.pdf
http://media.ccc.de/browse/congress/...ras.html#video

A summary as I understand it. VPNs relying on PPTP and IPSec are not secure, neither is SSH (are you listening, sysadmins?). SSL and TLS may not be either, but I'm unsure if they are saying SSL/TLS connections can be decrypted on the scale of millions of users, or just monitored and collected without decrypting, in hopes of decrypting later.

OTR, GnuPG, TrueCrypt, Tor/TAILS, CSpace, and ZRTP appear to be secure.

This is a major publication, and an extremely important CCC talk.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 01:04 PM
I finally see the appeal for things like heroku and pusher. A client approached me for a custom app that would be embedded in another app.

Free heroku tier works perfect for them and pusher.com let me setup websockets in a rails app in about 30 seconds to offer real time feedback on a background job.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 02:02 PM
heroku and pusher are pretty awesome. i used to be mad at heroku bc they're so overpriced (and they are) but they just save so much hassle.

also be aware: if you're using their free tier the app goes to sleep after an idle time, and then the next request that wakes it up can take like 5s to complete. this may not be a big deal, but it's worth knowing about.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 02:11 PM
Yeah I planned to use the free tier new relic plan too. I think it pings the app every minute to make sure it never sleeps?Free tier all the way for this current app since it's only being used internally.

My only concern with pusher atm is it seems pretty insecure by default. Couldn't someone just change the JS locally to listen to a channel that they aren't supposed to? It's a non-issue for this app atm but it'll be an issue later.

I guess you just take something like the user's ID and hash it with some other details to create the channel name? Not really secure, but better than nothing? I haven't Googled yet on this topic.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 03:17 PM
Quote:
Originally Posted by gaming_mouse
"Don't mock what you don't own"

http://www.mockobjects.com/2007/04/t...is-mocked.html

If applicable, you can write a thin wrapper over the 3rd party module, which delegates to the 3rd party module, and mock your wrapper. Otherwise don't mock and do an integration test instead.



you should never be writing tests for internal methods. if you find that you need to, or want to, it means something is wrong with your design. if it's truly "internal," then you should be testing it implicitly via the public methods that use it. if it's not truly internal, pull it out into its own class/function/module/blah or make it public, and test that. (EDIT: i should clarify here that this isn't free license to make all privates methods public. that's a design decision and shouldn't be influenced by your struggling with tests. that is, the testability should be giving you hints about the design. you shouldn't be bending your design thoughtlessly to achieve testability)




i'll got to great lengths to make the code more testable, but not by convoluting my code. the test friendliness should be making the code simpler. if it's not, you have a problem.
Thanks for the advice. Yeah I agree, I'll just test the output of the component - in multiple scnarios. That should be good.

As far as mocking the data I'm going to just make a dummy dir structure under test with dummy components in it. Then I can tweak those all I want to test different scenarios.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 05:32 PM
Quote:
Originally Posted by suzzer99
Thanks for the advice. Yeah I agree, I'll just test the output of the component - in multiple scnarios. That should be good.

As far as mocking the data I'm going to just make a dummy dir structure under test with dummy components in it. Then I can tweak those all I want to test different scenarios.
sure. in your case, if i understand it, the 3rd party glob library simply interacts with the file system to produce a list of files in a dir. so the input is a dir, and the output is a file list. if that's correct, i think it does make sense to create a thin wrapper around it, so you can use a mock to make sure your code is doing what it's supposed to on various file/dir structures that you create as test cases. there's really no need for an integration test, as it's probably safe to assume the 3rd party library does its simple job of listing out files correctly.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 07:01 PM
Quote:
Originally Posted by catsec
All,

It is my belief that everyone in the world, especially everyone in the world of IT, should watch this Chaos Communication Congress talk by Jacob Appelbaum and Laura Poitras, and read this new publication on an Edward Snowden document.

http://www.spiegel.de/international/...a-1010361.html
http://www.spiegel.de/media/media-35535.pdf
http://media.ccc.de/browse/congress/...ras.html#video

A summary as I understand it. VPNs relying on PPTP and IPSec are not secure, neither is SSH (are you listening, sysadmins?). SSL and TLS may not be either, but I'm unsure if they are saying SSL/TLS connections can be decrypted on the scale of millions of users, or just monitored and collected without decrypting, in hopes of decrypting later.

OTR, GnuPG, TrueCrypt, Tor/TAILS, CSpace, and ZRTP appear to be secure.

This is a major publication, and an extremely important CCC talk.
+1
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-29-2014 , 07:27 PM
Quote:
Originally Posted by gaming_mouse
sure. in your case, if i understand it, the 3rd party glob library simply interacts with the file system to produce a list of files in a dir. so the input is a dir, and the output is a file list. if that's correct, i think it does make sense to create a thin wrapper around it, so you can use a mock to make sure your code is doing what it's supposed to on various file/dir structures that you create as test cases. there's really no need for an integration test, as it's probably safe to assume the 3rd party library does its simple job of listing out files correctly.
Also the directory structure and dummy files will serve as some good examples for others on what one of my little components should look like.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2014 , 10:06 PM
how exactly does something like jRuby work? How is this different than coffeescript to javascript.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2014 , 10:10 PM
^Basically I'm looking for how someone who knows Ruby on Rails could quickly make simple Android apps. I'm looking primarily to test ideas than to learn an entire new skillset if possible. Thanks!
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2014 , 10:50 PM
JRuby executes ruby code on a JVM. It won't help you build Android apps. Neither will knowledge of rails -- that's a web framework written in ruby.

You can leverage your ruby knowledge to build android apps with RubyMotion:

http://www.rubymotion.com/news/2014/...ymotion-3.html

This will definitely save you some work, but one way or another you will be learning a new skillset. I think learning the Android SDKs, what features are available, best practices, etc, and then dealing with multiple devices, etc, is where the bulk of the work is in learning Android development (of which I have only a passing knowledge). So sure, using ruby instead of Java is nice, but there's nothing in the world that will magically let you make Android apps without learning a lot of new knowledge.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2014 , 11:23 PM
Thanks. I will be looking into RubyMotion.

Thoughts on something like Rhodes? I'm quite new to Ruby and Rails and development but seems like this is a decent option as well.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-30-2014 , 11:52 PM
I don't have an experience with Rhodes, but I'm skeptical about anything like that. I do have experience with Appcelerator and it was a disaster. It comes down to the fact that it's impossible to fully abstract away the native details, so all these "cross-platform" solutions have problems. If you're just interested in making a prototype and playing around, it may work fine for you, however.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 12:13 AM
Plenty of successful companies have built their mobile offering with ruby motion, phone gap, or even as a simple wrapper to an embedded web view. They typically move to a native app after they've fully ironed out the feature set and have gained some traction with the app.

I think for your purposes ruby motion will be good. Sure you'll still have to learn some android apis and framework specifics, but it will be easier to do so without having to learn java at the same time.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 05:31 AM
fyi my last comment does not apply to ruby motion, as it compiles to native code (at least in the case of ios, i assume it does for android too...) but we were warned about appcelerator, used it anyway to save dev time and money, and regretted the decision badly.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 09:28 AM
Quote:
Originally Posted by gaming_mouse
I don't have an experience with Rhodes, but I'm skeptical about anything like that. I do have experience with Appcelerator and it was a disaster. It comes down to the fact that it's impossible to fully abstract away the native details, so all these "cross-platform" solutions have problems. If you're just interested in making a prototype and playing around, it may work fine for you, however.
I haven't digged into it as deep as I planned to but so far PhoneGap/Cordova + Ionic (hold the Angular hate please) looks like a pretty promising combination.
You can dive in and do native if you want to.

Will report back when the entire app (planner/tracker for pub tours, yay usefull) is done and tested (yay pub tour). Big plus is the Windows Phone support which I don't even want to think about natively (it has a strangely high market share in Germany, I think it's a known outlier). Alas I won't bother with it since I don't feel like installing Windows anywhere. Maybe I'll use their cloud build for money thingy eventually.

Worst case I think it's a good intermediate step. Mockup stuff, gkue together in Cordova/Ionic and then you can still rewirte natively if you want to.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 11:41 AM
As mentioned above, the difficulty in learning Android is not learning Java, it's all the android specific stuff. It's not even all that difficult. An experienced programmer could learn enough Android to get started with their own project in a weekend.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 02:26 PM
In C++, if there is a void function x(), what is the statement if(!x()) doing?

It's in a unit test I am rewriting and I don't quite know how a void function is evaluated there and a quick Google search wasn't much help.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 04:00 PM
It's 100% a bug, maybe someone wrote the test and later changed the function signature?

When I try a really simple version of this in GCC I get a compiler error, so I have no idea what's going on. It seems like if you don't get a compiler error it would always evaluate false? But it really should be a compilation error
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-31-2014 , 05:30 PM
Someone changed the function without changing the test. I just removed it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m