Using JTAG allow you to take full control over the MCU. Depending on MCU hardware settings (see pin BOOT0 description for STM32F4), the MCU will decide if
- It will read the content of the application stored in flash into MCU's RAM. Then execute jumps to the beginning of the RAM address. This is the normal bootloading process, for final application.
- It will receive the content of the application through the JTAG into MCU's RAM. Then execute jumps to the beginning of the RAM address. This is the debugging/hacking process.
So, my answer to your question
Can I use the JTAG interface to the MCU in testing the app flashed on
to it ?
is No. You can't. But you can test the app that will be finally flashed to it with JTAG, and then flash it once you're happy with it.
Is there a way to automate testing especially for regression testing?
Sure, many ways but it really depends on your application. Consider a simple APP that will take INPUT data (from sensors for example) to produce OUTPUT data (LED lighting for example).
For non-regression testing it is a good idea to have a library of INPUT test data, for which you know the expected OUTPUT results. The main challenge there is how you could send the INPUT test data in place of the sensors. And this will depends on you application.
I suggest you to take the non-regression testing as a requirement of your embedded application, and consider an architecture where you could easily switch the INPUT data receiver from JTAG input to actual sensors.