How to run Gradle tests where I want to run a script beforehand

I’m running integration tests and have to run a script beforehand. I’ve used task:Exec(task1) to run the script. I have a task(task2) that has dependsOn for the task1, but how do I have task2 run task1 and my unit tests?