0

Can I use FlexUnit to unit test a File Upload and delete? Are those actions good examples of unit testing?

I'm a little new to unit testing and trying to figure out what parts of my UI are suitable for unit tests.

Thanks for any helpful tips.

fumeng
  • 1,771
  • 5
  • 22
  • 61

1 Answers1

2

The actual file operations will always be executed by native classes (such as FileReference), which you should not try to unit test - that's Adobe's responsibility, at least until Flex has left the Apache incubator.

As a rule of thumb: Always unit test only the code you wrote yourself. You can decouple it by replacing all external dependencies with test doubles (i.e. stubs or mocks, for example using mockolate).

weltraumpirat
  • 22,544
  • 5
  • 40
  • 54
  • I see, I'd be unit testing FileReference functions. That's a waste. – fumeng Mar 27 '12 at 19:28
  • 1
    Yup, so the way to go is mock FileReference and verify that all the calls to its API are made in the correct sequence, rather than trying to simulate an actual upload. – weltraumpirat Mar 27 '12 at 19:56