Tests dir is missing in my project - java

I (Git) pulled my (working) project on a different pc (on both pc's I'm working with Intellij-idea), I (Maven) compiled it but my tests directory is out of sync.
Trying to run it I get "0 test class found in package ''".
Ideas?

As it turns out, the Tests directory was not in the same hierarchy as my code.
The environment on my first pc was configured so it will bypass the issue and just run the tests as they are, but it is only a local bandage.
So if you come across a problem of that sort, first make sure that you have the same hierarchy level (code and tests), otherwise Maven will not find and run the tests.

Related

Can't load main class JUnitStarter when running tests on remote host via SSH on Intellij

I'm wanting to run tests on another more powerful machine to speed up testing time, so I've created a run configuration on Intellij which targets my Ubuntu machine rather than my local one.
If I don't use rsync to copy the files to the remote target, the tests all work fine, however when I enable rsync in IntelliJ, I get the following exception when the tests attempt to start:
Error: Could not find or load main class com.intellij.rt.junit.JUnitStarter
Caused by: java.lang.ClassNotFoundException: com.intellij.rt.junit.JUnitStarter
Process finished with exit code 1
Although I could run without rsync enabled, the copy process to the remote host takes longer than running the tests on my local machine.
For context, my local machine is running Windows 10, and my remote machine is running Ubuntu 20.04.
Thanks in advance!
EDIT:
After doing a bit more digging, I found that rsync is copying files in the maven repository and Intellij Ultimate folder using the MS-DOS file structure style. This means that as part of the copy, it's using backslashes instead of forward slashes resulting in linux thinking it's part of the name of the .jar file. In result, it means that the copied maven repository folder is in the wrong file structure:
Changing the file structure manually fixed the issue and tests run successfully however it's just a work around and doesn't directly fix the problem but at least points in the right direction.
This is a bug: https://youtrack.jetbrains.com/issue/IDEA-270106
Will be helpful if you can vote for it and attach idea logs there

Running Java program on iSeries on command line

I've created a java program and I'm wanting to run it from the iSeries. I've been able to get it to run from the QSH so I know it compiled and runs fine, but I need to run it from the command line not QSH. The program requires the jsch-0.1.55.jar file for the program to work correctly and I'm not 100% sure how to to call the jar file with the program its referencing to.
I've tried
RUNJVA CLASS(ANL0106J) CLASSPATH('/JAVA/Jars/jsch-0.1.55.jar')
That didn't work. Then I tried
RUNJVA CLASS('/JAVA/Jars.jsch-0.1.55.jar':. ANL0106J) CLASSPATH('/Java/Jars/jsch-0.1.55.jar')
That didn't work either. What am I doing wrong?
Having successfully done this many many times, your last try seems pretty close, but change the CLASS parameter to point to your class file which contains the main method. ANL0106J seems like a pretty weird class name.. Example would be:
CLASS(com.company.test.ApplicationMain)
With the CLASSPATH pointing to the required jars using the full path names. For example:
RUNJVA CLASS(com.company.test.ApplicationMain) CLASSPATH('/test/app.jar:/test/dependency.jar')
To make matters a bit easier, you could even include your dependency in your JAR file by using something like maven or Gradle to create your builds, which can then be configured to generate fat jars. Essentially, those are jars that contain the other JAR files that your application depends on. That way, you can also be pretty sure that your application will continue to work, even after you update a single jar file on your ibm i machine for example. Shadowjar for example is pretty easy to setup using a gradle project which will do this for you. Then it's just a matter of running the bootjar gradle task and using the RUNJVA command, simply pointing to your single JAR. Don't get caught up in dependency management hell, please. Save yourself and future devs by using something like maven or gradle. Gradle/maven can even be used to manage depencencies using a maven repository with a tool such as Sonatype Nexus which can also be hosted locally. If your JAR has a valid manifest, you don't have to do anything else. It would look like this:
RUNJVA CLASS('/test/app.jar')
Especially useful for using CI, which can build the JAR for you from a GIT repository and place the fat jar in the correct path, with you not having to do a single thing. Setting up Jenkins on an as400 isn't that difficult at all using the apache WebSphere application server which is an option that can be used to host WAR files, to put it simply (it can do a lot more than that though :P).
Hell, using only a single jar for the RUNJVA command should also speed up the time it takes to start your application since it only needs to verify a single jar. Just food for thought. Here's the maven entry by the way:
https://mvnrepository.com/artifact/com.jcraft/jsch/0.1.55
On a side note for java/react devs: Yes, fellow Java/react developers, one could use the RUNJVA command to modernize ibm i development to run Spring boot applications! We are successfully running react front end applications using a spring boot backend system, Works extremely fast, as expected :)
(Same answer given to you on Reddit, simply on this platform to make it visible for others that are looking for this on Stackoverflow)

Run selenium webdriver IntelliJ/Java/JUnit w/multiple computers on same central project folder

I would like to have laptops and vm's creating, maintaining and running selenium tests all from the same common IntelliJ Project folder on a network shared drive.
Is it possible to setup a centralized project folder for IntelliJ so that multiple computers with IntelliJ installed running Selenium Webdriver and JUnit can execute the same tests from a singular location even at the same time? I am not using robot.
I am using IntelliJ 2017.2.3, Java 1.8.0_121, JUnit 4.12, Maven 3.3.9
My advice here would be to do the following:
Make sure your project is in a reputable version control system (GitHub/Git)
Determine your exact requirements of why you need to carry this out?
Research selenium-grid (you can run tests on multiple browsers/devices at the same time, this way you could run them on one machine pointing to one grid instance, and on the other machine point it to another.
Look into CI/CD (Jenkins) - This will allow you to parameterize your tests so you can kick them off at specific times pointing to different grid instances.

Scriptable Eclipse run/debug configuration [duplicate]

I'm finding it difficult to phrase this question well, as there are quite a few generic terms (run, configuration, launch, etc.). Here goes:
You can save run configurations in a .launch file. (in the Run Configuration Dialog, under the Common tab, Save as a shared file.
We check these in to SVN. The developers can pass them around, and it helps getting new devs running a working application quicker.
I'd like to check these out as part of our build and use them to programatically run the application, the tests, etc, without spinning up the whole IDE.
What would be the best way to run a .launch file outside of the UI?
Edit: I am trying to unify the tests run on the build server and the IDE. I do not
particularly want to give up integrated debugging, which would be the case with an ant script to run the tests .
This is probably more a problem for integration testing with multiple bundles, or unit testing a whole bundle, where you'd like to mock up extensions.
there is an eclipse plugin built over JUnit, called TPTP. It provides an automation client which can be used to launch the test from eclipse with no gui. maybe it helps
Ant4Eclipse may provide a good starting point on how to do this.
Unfortunately, this is limited to Java Applications and JUnit configurations; I am more interested in PDE applications and Plugin JUnit tests.
I have recently had alot of success building an Eclipse RCP app inside a Hudson CI server using Eclipse Buckminster. It took a bit of doing, but once I setup both features, made my RCP product be based on features, and added the Buckminster query files and the like, it worked. There is a Hudson/Jenkins Buckminster plugin that allowed me to have hudson build the application.
After saving the launch configurations for each test fragment, I created hudson commands to invoke them (yes one line per test fragment unfortunately), but after that I got the automated CI build that I wanted.
You could also use the shell command Eclipse uses. To get it:
Run your program in Eclipse
Go to the "Debug" view
Right-click on the process (probably the second item in the tree) and select "Properties"
Copy shell command and delete the agentlib flag to run in bash
I think you don't need to use the .launch configurations to run the tests. If you build an application using the Eclipse Build System, then you can use the AntRunner application from Eclipse to run your units tests. This doesn't start the whole IDE.
This article describes how to run the tests during your build process. With this process, you use a special "Test" Eclipse and load the plugins you want to test.
Perhaps running the configurations the way you would run your own custom run configurations would help here. It is described in this article.

Maven tests pass in Windows 10 but fail in Ubuntu 16.04

I have a Spring Boot project which passes all it's tests under the mvn clean install command in Windows 10. The same exact code base, against the same database, has some test case failures when executing mvn clean install in Ubuntu 16.04. I traced the problem to a directory not being created by the code inside a failing test case using the mkdirs() function. I don't know why, I mean, I own the project so I wouldn't think it's a permissions issue. I cloned the project in Ubuntu from the remote repository using Intellij IDEA's built in Git functionality. Many of the other test cases (hundreds of them) are passing but a few fail and they are all related to this mkdirs() issue. Just to reiterate, the problem only exists in Ubuntu 16.04, not in Windows 10 where all tests pass. If more information is needed please let me know I'll provide.
Is there any way to resolve it without altering the code?
I found that the issue was a root directory setting being set in a configuration file of the code base. While that root directory would be openly accessible on a Windows platform, on Ubuntu it was restricted. Changing the setting in the configuration file to point to a base directory where I know I had write permission solved the issue.

Categories