0

I need to detect at runtime from the code if the application is run using an Instrumented Test. I'm looking for a solution that works without knowing the Test class.

Junzo
  • 1
  • 7
  • Why? Changing the behavior of the application when it's under test potentially defeats the purpose of testing. – Kevin Krumwiede Jun 27 '17 at 19:43
  • I need my application to work only if under test – Junzo Jun 27 '17 at 21:41
  • But why? It sounds like you're deliberately trying to get some broken code past automated tests. In other words, it sounds like you're trying to sabotage a project. It would be irresponsible to help you without an explanation. – Kevin Krumwiede Jun 27 '17 at 21:52
  • Could not I just be a researcher? Or a security fan? It could be a thousand of reasons and instead of writing this things, I could just look for a loophole and tell you something like "I'm a university professor and I teach Mobile Application. I need to know if my students can somehow succeed in bypassing my tests". Even though such a thing is credible, you may continue doubt my good intentions, so why do you seek explanations? – Junzo Jun 28 '17 at 07:58

1 Answers1

0

You can read logcat logs in launcher activity of your application under test and find the instrumented test launch command in logs.

Lalit Pal
  • 41
  • 7