I am new to automated testing. I am trying to set up a Maven project for my Selenium test automation work. I put all the packages pertaining to envVariables, library, settings, resultLog, errScreenshots etc under src/test/java.
I have a couple of questions here
i)I showed this framework to my developer and he asked me to move some of the packages under src/test/resources. I am not sure whether this needs to be done or whatever I have configured is correct. If I need to move the packages to resources folder, what packages should I move? Can somebody please advise me on how to configure this?
ii) what should the src/main/java folder contain? I thought it will contain the src code of my application and test folder would contain unit tests and selenium tests. But my developer says the test folder will contain only unit test that test the classes in the src/main/java. It should not contain my selenium tests. Can somebody please explain this to me?
Regards
vasu
I am not sure about the structure of your automation project. I prefer the following hierarchy in MAVEN projects
src
|-----main
| |-----java
| |-----Pages (contains application code arranged as one Class per Page)
| |-----Steps (calls the page objects and methods called in Pages)
|-----test
|------java
| |-----Test (Opens browser and calls steps to perform test - TestNG)
|------resources
|-----InputSheets
|-----Environment Variables
The results are saved in C or D drive and are time stamped to avoid getting overwritten.
The automation helper library is created as a separate Maven project and is added as a dependency to the test project. In this way the helper library is independent from the test project and can be used across all projects if need arises.
All this being said, much of the structure is a matter of choice and varies according to your project requirements.
"src/main/" is for production code or test automation framework, not for test cases. "src/test/" is for testing stuff, including selenium tests. "java" folders are for classes, "resource" folders are for configuration and test data.
I suggest creating a separate maven module for your testing stuff: test framework and test cases.
Please refer maven directory layout page for more information.
UPDATE: I have created sample maven project to show how run selenium test with selenide.
Related
Our non-technical business team need to run only 1 automation test script which will be fetching data from several hundreds rows of Excel file. I've created automation that script using a Maven project (with POM framework and Extent Report), using Selenium WebDriver, Java, TestNG, and Eclipse but not sure how to deliver the test/script to the business team. Would appreciate if you guys can suggest a few options to deliver this script to the business team so that they can change few parameters in Excel file and run the script on their own. I'm getting Extent report at the end of the test, would be best if they can get the Extent report as well.
Note: Since they are non-technical, it is preferable to avoid installing and configuring Java, Eclipse, etc tools on their machine but that's not mandatory so I'm open to check several options.
I would like to suggest few options here :
Jenkins - Install it on Any server and share login and url with them. They can execute build and no technical knowledge required.
Executable JAR - Export your project as executable JAR and deliver that JAR file. All they have to do it , Double click on JAR file OR execute via batch file and it should run that script and get done the job. Make sure all data related file should be there with JAR. i.e excel file
Note : They always need JAVA in the machine regardless of what they prefer from above to use.
Usually i used to give as batch file script, if you have jenkins, integrate your bat file in it. other wise share the batch file as it is.
Create a package JAR,
Create .bat file to execute the JAR.
I have 2 projects.
Project A - This is an aspectJ project. For example: It prints the method name and time taken, in console after execution of each method.
Project B - It is a sample web project.
I want to add Project A as a Jar to Project B. So whenever I run Project B, it should display what are the method names and time taken.
Since I am new to AspectJ , could someone explain how to do this. Please explain with some sample projects.
Thanks in advance.
You have several options:
Use A as an aspect library when compiling B with the AspectJ compiler Ajc. This can be done from command line, from IDE with the right project configuration or, most conveniently, via AspectJ Maven plugin.
Use A as an aspect library and B as a weave dependency in a post-processing step with Ajc. As before, this can be done from command line, from IDE with the right project configuration or, most conveniently, via AspectJ Maven plugin.
Use load-time weaving (LTW) via -javaagent:/path/to/aspectjweaver.jar command-line switch when starting your Java application containing B and put A on the classpath as an aspect library.
For more information please use your favourite web search engine, specifying search terms like "aspectj ltw", "aspectj maven plugin", "aspectj ajc" or similar.
P.S.: Why should anyone provide one or multiple full sample projects if you are too lazy to provide a single line of code?
I have a project that consists of an Umbrella App. The child apps under the umbrella consist of a core/main/domain application a delivery app, a database backed repository and an in memory repository.
I would like to write a few integration tests that send http requests and check the changes in the database. As these tests require the coordination of several of the child apps these tests belong in the umbrella app and not in an individual childs test directory.
The default umbrella project does not get created with a test directory so I am unsure where they belong.
I have created a test dir and added a test_helper.exs that calls ExUnit.start and a project_test.exs test. but when I run mix test from the umbrella directory it only finds test in the apps/component/test directory and not the tests in the test directory
The umbrella project is meant to be an umbrella facility really, you can't add code nor tests to it. I can see two options:
Add the tests to the application that depends on all others (if you have one)
Create another application in apps that is where you will store all integration tests
In any case, remember that ExUnit has the concept of tags and you can tag all integration tests as such and use the tag system to include/exclude tests at will. This should help you manage tests as they grow in number.
Ok, so I'm working on a project using IntelliJ and trying to take advantage of its cucumber functionality. I've not worked with the java flavour of cucumber, but IntelliJ seems to want the step definition files in a specific location, relative to the feature files.
I found this: how to define step definitions location for cucumber in intelliJ 12 and other sources that pointed me to been able to add the "glue" property of my run configurations which tells cuke which package to find the step file. So I am at a point where I can run my tests via IDEA. BUT I need to set this every time I run a new test, as Ctrl+Alt+F10 or right click+run test will not start the test with this flag. Also, the ide support is screwed as IDEA doesn't know where the steps are, it doesn't auto complte or Ctrl+Click navigate to steps.
Is there a way to the the IDEA project to always look for steps in a given package both when running the tests and for its auto complete?
Creating self answer for others who might have this problem. My project did not have the steps marked as test source root, and although I DID do this, it was not until I closed and reopened my project that they were picked up. So a simple restart was my answer.
You can set the glue location globally by opening "Edit Configurations -> Defaults -> Cucumber Java -> Glue" and add the package names.
(IntelliJ 12.1.4)
Go File->Settings--> plugins
Install Cucumber for Java plugin
Then you can manage cucumber plugin as shown below
This should redirect you to step definition when you click your test.
Hope this helps
IntelliJ supports a plugin for Cucumber-Java/Groovy. Installing this plugin will enable the navigation from Steps mentioned in the feature file to the Step Definitions.
And after creating the Step Definition, navigation is easily possible
I go in EditConfiguration, Glue section and i put the path from the package above and the package where is your class for steps, ex:
CucumberFramework.stepsDefinitions
It is really nonsense :) but in in my case when IDEA refused to add steps definition automatically due to some plugins installed, e.g. Cucumber for Scala and suggested deleting them that i cant since i need them in other project. So, long story short, to add (Create step definition) you need to create Class in 'glue' dir and some fake Cucumber implementation, build one more time and it resolved my issue.
Background:
When I use IDEA 2018.2
And Java 8
And Cucumber info.cukes:cucumber-java:1.2.4
#When("^I created a Class and put there fake step implementation$")
#And("^I run gradle build one more time :)$")
#Then("^This Class will be able for me from the feature file by ALT+ENTER as usual$")
#And("^It resolved my issue when I was not able to automatically generate step definition$")
I'm developing a Solr plugin and using the Solr test-framework I place a test SOLR_HOME dir under test/resources with /conf/ and /lib . Now the framework inistantiates a SolrCore and loads my plugin from /lib. Not an issue to output the jar of the plugin to /lib, but the issue is that the plugin is not yet available since it still needs to past the test (chicken and the egg).
How do you recommend solving this? I see those options:
Create another project for the tests with a dependency on the plugin, and in it run the tests. Simple enough, but how do I ensure that everytime the plugin is built also the tests of this other project is built? The point of the automated tests at every build is to having a new plugin jar which breaks the tests.
In dp4j pom.xml I build the project on 2 phases, in the 1st I <include> only the annotation processors while in the other I compile the tests which rely on the annotation processors compiled in the eariler phase.
I'm in favor of 2 since copy-pasting the configuration doesn't seem a bad option, and makes it seem less complicated than it probably is. I don't remember if I had asked about it here - what do you recommend? Any other case studies /working code to look at?
there's a 3rd. most probably best solution ~ do nothing!
I was under the impression that the Solr Testframework need to load my plugin from /lib but apparently it doesn't need to, it can load it from test-classes, all on its own!