Skip to content

u/jmalloc

In this archive from Jan 2012 to Jun 2017

1
posts
44
comments
0
media
142
score

Top posts

Top comments

On the topic of adoption, one of the major drawbacks of such a system is that to see widespread use there really needs to be a good set of asynchronous libraries for all the things we already do so frequently in the PHP world (pdo, redis, etc), and furthermore those libraries need to be built on the same event loop in order to be interoperable.

I'm hoping that by basing the kernel on React and trying to make the use of React's promise-based code feel very native inside Recoil that some of the issues are are mitigated to some degree. There is a growing group of people doing some cool stuff with React.

Thanks for your interest :)

8 points

Hey, so this is my repo.. how surreal. The README is just a default template at the moment, so if it's not obvious "woodhouse" is actually a command line utility we use inside another project (IcecaveStudios/testing) which actually runs the tests and knows what content to publish.

The "testing" package is a dependency we include in all our projects to ensure consistent configuration of Travis and PHPUnit, etc. I'm currently working a new version of "testing" that should make it a lot more useful to the rest of the world, as at the moment it makes a lot of assumptions about the way your repository is organised.

7 points

As time goes on, with large projects, I've tried to reduce usage of static methods considerably. When used carelessly they can make testing a nightmare, or worse actually destroy your ability to properly decouple your classes.

My general rule of thumb is that static methods should be deterministic, that is, having no state, any given input will always produce the same result. More often than not when they are present in our codebase they are helpers for constructing, something you'd achieve with a constructor overload in other languages.

I don't agree with the fairly common advice that any method that does not touch $this should be made static, especially if you're producing a library for use by other developers - doing so destroys end user's ability to modify your class' behaviour by overriding that method.

I hope that makes sense and possibly even helps ;)

7 points

I can see what you're getting at, and your general idea is correct - as far as validation is concerned the unit testing framework can indeed only perform rather basic comparisons, you still need to bootstrap your code and provide the expectations to the framework. [Though this is easy because all of your code is well abstracted and makes good use of patterns that ease testing, such as dependency injection, right? :)]

So what does the framework give you? Where I work we use PHPUnit to run our tests, not only can it tell us if our code is working, but it can also give us coverage information - telling us exactly which lines of code were executed, how many times and by which tests.

Our tests are also integrated with a continuous integration server (we use bamboo). This means that every time somebody commits code changes to our subversion server the tests are fired off and we get a warning if any of them fail. As an added bonus the developer that caused the test failures can be shamed in public :P

Another feature that a testing framework provides that is often used very heavily is a mocking facility. Simplified, a mocking system allows you to create new subclasses of your existing classes at runtime in order to [re]define expected behaviour. Largely mock objects are what allows you to isolate the actual "units" of code you want to test, even when they depend on other classes/methods/etc. PHPUnit provides it's own mocking system, though recently we've been moving to Phake, which is proving much more flexible.

Apologies for the long-winded response, but I do want to encourage anyone reading this to give unit-testing and/or test-driven development a go. If you've never done it before you'll be amazed at how it forces you to write code that is more easily tested, which very often means much better designed and abstracted :)

7 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.