简体   繁体   中英

How can I use javac to cross compile my old tests to be compatible with java 8?

I work for a company that is currently developing a server software and it is my job to run automated tests for this software. The newest version of the server is built using Java 8, and this is causing problems because our old testing framework is made to accommodate Java 7. We use the TestNG plugin for java to run all our tests, but as far as I can tell, every single version of TestNG is compiled with java 7, so if I compile the tests with java 8, the plugin will throw a major.minor unsupported 52.0 error if I try to run them with the plugin. On the other hand, compiling the tests with Java 7 causes the same error to occur when the tests try to send requests to the server.

How can I cross-compile these tests so that they work with both TestNG and the server? The interaction works like: TestNG calls the tests, and then the tests call the server.

I've read up on this a little and I think I need something like:

javac -source 1.7 -target 1.8 projectName

Is this a viable approach?

Yes, I faced the same issue in one of my projects. javac -source 1.7 -target 1.8 projectName worked fine for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM