I recently encountered tests that fail when run in IntelliJ (and I haven't been able to resolve why yet, but likely due to threading). I was able to resolve this with a single test case annotation that tests for an environment variable that only IntelliJ sets.
I know this is written for Junit exclusion but wanted to share as a possible partial answer to the need since I spent some solid hours searching for a solution and this discussion was the closest I could find.
@DisabledIfEnvironmentVariable(named = "IJ_RESTARTER_LOG", matches = ".*", disabledReason = "Fails when all tests run in IntelliJ")
java.library.path
containsC:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.0.1\bin
, or something like it – CecumWindows
. See my answer below for a platform-independent solution – Fiume