Can't choose class as main class in IntelliJ

Solution 1:

Select the folder containing the package tree of these classes, right-click and choose "Mark Directory as -> Source Root"

Solution 2:

The documentation you linked actually has the answer in the link associated with the "Java class located out of the source root." Configure your source and test roots and it should work.

https://www.jetbrains.com/idea/webhelp/configuring-content-roots.html

Since you stated that these are tests you should probably go with them marked as Test Source Root instead of Source Root.