• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Testing Resources Location

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I am testing things like image resizing, unzipping files, etc. For a bunch of util stuff. Is there a "best practices" solution of where resources like ZIP files and image files are stored, etc? Or is one place just as good as the other?

Along these same lines, aside from testing whether or not the specific util method craps out, is it ok to do something like...

File file = new File("assumed/unzip/location");
Assert.assertTrue(file.isDir());

??

Thanks.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gregg,

I tend to favor generating unreadable binary files (such as .zip) at runtime but if that's not feasible, then I'll shove them under "src/test/resources" (I'm nowadays mostly using the Maven Standard Directory Layout).

I'm not sure if I understand what you're asking here:

Along these same lines, aside from testing whether or not the specific util method craps out, is it ok to do something like...

File file = new File("assumed/unzip/location");
Assert.assertTrue(file.isDir());


...but I'll answer something anyway

I generally use the system temp directory for any file system residue from my tests rather than a path that's relative to the project root.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lasse. As to the latter half of my post what I mean is I just want to run a test that verifies that my file unzipped in whatever path I specified to to unzip to. So I need to test that all the files are actually there. Maybe I shouldn't need to test that? Just trying to cover all the use cases.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:
I just want to run a test that verifies that my file unzipped in whatever path I specified to to unzip to. So I need to test that all the files are actually there. Maybe I shouldn't need to test that? Just trying to cover all the use cases.


It's rarely black and white.

In your case, I'd probably end up writing "pure" unit tests for the surrounding code base without any actual zip files involved and write a couple of integration tests for the teeny-tiny piece of code that actually invokes the API.
 
reply
    Bookmark Topic Watch Topic
  • New Topic