Running evosuite generated tests in Eclipse - evosuite

I have generated the test cases using evosuite from the command line in Linux.
I try to execute the tests in Eclipse. I have imported in my project the evosuite-standalone-runtime-0.2.0.jar.
All the imported classes regarding evosuite are marked with the error sign.
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.evosuite.runtime.testdata.EvoSuiteFile;
import org.evosuite.runtime.testdata.EvoSuiteLocalAddress;
import org.evosuite.runtime.testdata.EvoSuiteRemoteAddress;
import org.evosuite.runtime.testdata.EvoSuiteURL;
I don't understand this. It looks like these classes are unknown even though are in the imported jar file.

Try:
Right button in your project-->build path--> Add External Archives
(select evosuite-0.2.0.jar)
Do not forget to put the two classes in the project. (ESTest.java and ESTest_scaffolding)
I hope this helps.

Related

Installed modules not found, but show up in python interpreter config

I tried to install EZGmail module for Python. When I check my interpreter settings, it shows it as installed in the PyCharm list. I then use this same interpreter for my project, but I get a module not found error when trying to import EZGmail. What should I check?
Looks like you're trying to import the module in a different casing than it's mentioned on the document.
You're trying to do:
import EZGmail
while the Quickstart document says:
import ezgmail

Cucumber feature file unable to locate glue code when clicking on Recalculate Steps and throws error message

I am currently working on creating a Test Suite using Cucumber framework. I have created feature files for each of the functionality I have to test.
The feature file never shows the conditions to be covered via glue code. On click of Recalculate steps it throws an error : An internal error occurred during: "Scanning for step definitions".
java.lang.NullPointerException
I tried to change the path of glue in the Test Runner class but it did not solve the problem as well. The feature can be executed without any issue and the code runs fine, only issue is feature files keep on stating that there is no matching glue code.
#OrderInteraction
#Orders
Feature: Validating Order functionality
Background: Pre-requisites of Order Functionality
Given WebDriver is initialized
And Website is up and running
When User Enter "Username" and "Password" as Credentials
Then Validate User Login
Test Runner :
package Cucumber;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
#RunWith(Cucumber.class)
#CucumberOptions(features = "Features", glue=
{"src/main/java/CucumberStepDefinitions"})
public class CucumberTestRunner {
}
I would like to find a way in which Cucumber feature files can recognize the glue code present. Feel free to guide me to a existing question which answers this or a documentation which will be of help.
There is a possible solution in this discussion https://github.com/cucumber/cucumber-eclipse/issues/303
Which basically says to make sure you don't have
import cucumber.api.java.en.*;
in your steps files, and to use
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
instead.
Which fixed it for me
I finally was able to find the solution to this issue. Issue lies with the cucumber plugin version, I referred to Cucumber-Eclipse-Update-SiteSnapshot for resolution.
The steps were as below :
1.From Eclipse, go to menu Help > Install New software
2.Work with: https://cucumber.github.io/cucumber-eclipse-update-site-snapshot
3.Select the check-box for Cucumber Eclipse Plugin
4.Select Next as per the instruction shown during installation.
5.Restart your Eclipse after completion of instruction.
Once the plugin was updated Feature file automatically scanned for steps and found the matching glue code.

Robot not able to import .java library

I am trying to import the 'SwingLibrary' into my Robot project and have had a lot of issues with it. I was able to work around my first error that seems very common by removing the version number from the file name:
Importing test library 'SwingLibrary' failed: ImportError: No module named SwingLibrary
Now everything is named SwingLibrary (jar & xml included) so I got a little further but I am now seeing the error:
Importing test library 'SwingLibrary' failed: Expected class or module, got javapackage.
I know Robot is supposed to know when it's trying to import a python or jython package but for some reason it doesn't seem to be working here. I did not have an issue importing the java version of Selenium or any of the standard libraries.

Import org.apache.commons.io.FileUtils; not possible in latest apache poi.Instead import org.apache.tools.ant.util.FileUtils; is coming

In the latest Apache poi download(poi-3.15-beta2), while taking screenshot, I need to use FileUtils.copyFile. In its previous version, the imported package was import org.apache.commons.io.FileUtils;. In the latest download, this package is not coming, and it is giving error in my existing executable code. Now I tried to remove the previous import and it gave import org.apache.tools.ant.util.FileUtils;
Code:
FileUtils.copyFile(
scrFile,
new File(location+"LR_"+strDate+"_scr1.png")
);
Gives the error:
Cannot make a static reference to the non-static method
`copyFile(File, File)` from the type `FileUtils`
Apache POI never bundled or required Apache Commons IO, which contains the FileUtils class and so it seems some other project dragged in this code previously, but does not any longer. See http://poi.apache.org/overview.html#components for the list of third-party projects that Apache POI uses.
You should simply add a recent commons-io dependency to your project depending on which type of buildsystem you use, e.g. a normal dependency in Gradle/Maven or the actual jar-file if you have a buildsystem without full dependency-support.
Use the code below:
FileUtils.getFileUtils().copyFile(sourceFile, new File(directory + filename));
And import file should be:
import org.apache.tools.ant.util.FileUtils;

Import another python script, using PythonInterpreter

I am trying to execute a python method from eclipse using jython. I managed to run it with following code:
PythonInterpreter.initialize(System.getProperties(),
System.getProperties(), new String[0]);
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("Mypython.py");
interpreter.eval("MyClassName().MyMethodName()")
My problem is when I import another python script, which exists even in the same directory with Mypython.py. For example, when I add:
from food import Pizza
to Mypython.py, it starts to complain that cannot import. ImportError..
I found some questions about importing python libaries like os, but in my case this is not an issue.
I tried to make the folder as a package, add init.py etc but it failed. I saw some people use PySystemState, but I think it is for jython modules not user python scripts. if this is the solution please give me a simple example.
Could you please help me with that problem.
sys.path is your module-import search path. You can import sys and then modify sys.path as required.