We can set "group-by-instances" as true in TestNG.xml file. Tests will execute class-wise based on the priorities set.