What are the possible ways to report or capture the result?
Or should we keep on staring at the screen when the automation script runs?
Thanks in advance!
You can get the test report using testng.
First install testng by following this link
After installation of testng, write some test cases in a class using #Test
annotation. Then click on run and run as a testng test. Then refresh your project and in test-output folder, you will find the testng report.
If you google, you will find a lots of links about this.
You can go through this link
Selenium (like other browser automation frameworks) is most commonly used to write automated acceptance tests within a test framework such as Cucumber-JVM. I mention Cucumber-JVM since it's designed for acceptance testing and is the most common such framework used with Java applications, but you could use JUnit or TestNG or another test framework if you wanted.
In any such framework, within each test, Selenium or another browser driver simulates user actions in the UI and statements written in the test framework's API/DSL assert that the expected result occurred. The test framework runs all of the tests and reports any which failed.
It is still often useful to watch the screen while debugging a failing test, however.
you can take screenshots of the screens, then you can create PDF's/doc's if you need. to capture screenshot you the command
screenShotImage = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
use screenShotImage.getAbsolutePath() to get file path.
Test results are always linked to project needs, i have seen scenarios where test results should be in PDF.
Here are some suggestions on test results
Extent reports - This is the java library contains graphs as well as
detailed steps. This even allows screenshots
If you are using TestNG or Junit, it has default reporting. However if you are looking for more advanced graphical report, use
RealTimeReport
if you link the results in documentation, create a custom report code
Related
I am a beginner at automation testing.
I am trying to execute tests that were written in java using Selenium WebDriver, Cucumber with Gherkin annotations in JMeter.
When I run my tests without JMeter, I just use the opportunity to run them as Junit test using the runner class (in Eclipse).
To run my tests in JMeter, I created a jar file, uploaded it to Junit sub-folder, all dependencies-jars were uploaded to lib sub-folder.
I tried to create a JUnit request in JMeter, but it didn't help as when we use Cucumber, we don't mark methods with #Test. I have just an empty constructor for my Runner class (as you can see from the picture above).
I tried to add my jar to Test Plan and create an instance of my class in BeanShell, but it is not executed as JUnit tests.
My question is how to run java test scripts that were written based on Cucumber with Gherkin (based on Selenium WebDriver)?
Maybe I have to use other Samplers...
Any examples are greatly appreciated.
I believe you need to run another class, in particular io.cucumber.core.cli.Main, something like:
io.cucumber.core.cli.Main.main(new String[]{
"--glue",
"the package which contains the glue classes",
"/your/feature/file"});
Check out Running Cucumber -> From the command line for all the available arguments explained. By the way, you can use OS Process Sampler for this, it will be way easier.
Depending on what you're trying to achieve it might be faster and easier to convert your Selenium tests into "native" JMeter ones as if you're going to use your Selenium tests for creating the load it will require immense hardware resources and you won't get performance metrics on the HTTP protocol level.
I am an entry level tester, mainly been doing manual testing for a company in the UK following scripts on a spreadsheet which I have written in the BDD format, however, I have been learning some automation on the side as that's what I want to move into full time. I have some questions though which are as follows.
I've been using Selenium web driver + java bindings to make simple tests such as logging in or filling out a registration form, i've also set up log4j but only basic to record low level recording. I have now come across testNG. My main question is this framework used by testers? or developers? Is testNG only for unit tests? or UI tests?
From what i've learnt so far the developer does the unit and component tests and the tester does the services/ui tests is this correct?
Unfortunately I was put into a team of developers and not testers as this is my first job outside of university. So I haven't had the chance to learn from other testers. There was no plan for me when I started just that I was going to be the first tester in this development team without any prior testing knowledge.
Which is why I need a bit of guidance on these issues.
My main question is this framework used by testers? or developers? Is
testNG only for unit tests? or UI tests?
TestNG can be used for both, developers and automation testers, it is a tool that can operate over and together with Junit, basically in some cases is being used to create the concept of test suite, that allows to split all the test cases based on specific criteria (time, module, complexity). Also this framework can be used in unit testing and integration testing as well as ui-testing.
TestNG also in some cases replaced Junit entirely, whit this approach you will have a framework with some out of the box capabilities as DataProviders, Multi threading support and other, you could check this link, consider this as and powerful option for Junit.
From what i've learnt so far the developer does the unit and component
tests and the tester does the services/ui tests is this correct?
Unit testing which I consider very similar as "component test" is being done by the developers. If you have web services or a REST API, developers sometimes are in charge of create some test using integration testing, basically verify that services are working as we expected, returning JSON/XML with the correct format and other kind of validations.
Testers also could check services, using tools such as Jmeter, SOAP-UI, they check more things related to the business logic.
Finally I would said UI test is being done in most of the places by the manual and automation testing team, in places where is no QA department this tasks also belongs to the DEV team.
In order to run tests you need to have a test runner it could be anything, most common in java world is JUnit and TestNG, with those frameworks you can run the tests which annotated by #Test tag, also you can group the tests the way you want it and run them in parallel.
Testers use it to run Selenium tests and do assertions, even though for assertions it is good to have knowledge of hamcrest matchers. Also it providing you reports after tests been completed.
Developers would use same frameworks for unit testing purposes.
Check out guys from toolsqa.com they have pretty comprehensive tutorials on using Selenium with TestNG.
TestNG is basically used by developers for doing unit testing, I agree. But it is also widely used by system test automation using Selenium. This framework is inspired by JUnit framework, and most of the automation test developers use this framework because of its advantages and more added features to support reporting.
I can say following advantages I got by using this framework:
1.Support for parameters.
2.Supports dependent methods testing.
3.Test configuration flexible. Supports powerful execution model.
4.Embeds BeanShell for further flexibility.
5.TestNG has a more elegant way of handling parameterized tests with the data-provider concept.
6.For the same test class TestNG support for multiple instances.
7.Extendibility of using different Tools and plug-ins like Eclipse, Maven, IDEA etc.
8.Default JDK functions for runtime and logging (no dependencies).
9.Supported different Annotations like #BeforeSuite, #AfterSuite, #BeforeClass, #AfterClass, #BeforeTest, #AfterTest, #BeforeGroups, #AfterGroups, #BeforeMethod, #AfterMethod, #DataProvider, #Factory, #Listeners, #Parameters, #Test.
The most beautiful part I found in testNG is, using data provider, i can easily read test inputs and expected results from excel. And I can able to see the Results of Pass/Fail and skip test cases in an emailable format.
For testing a system, we don't need any training/extra classes. Just if we know the system requirements, and this as a end user what they want from the system and start testing. If any deviations found in the system behavior and are not as per the expectations of user. Then mark it as an issue and raise a defect and track it until it get resolved. Retest the same and confirm that the system is working as per the expectations. even at the Unit test level this principle holds the same. But only the difference is that we can do Structure based testing there.
To your questions ..
1.My main question is this framework used by testers? or developers? Is testNG only for unit tests? or UI tests?
Answer = Test NG can be used for unit testing as well as UI testing. the advantage of test NG over JUNIT is that you dont need to write code for test result reporting.
I am really new to Fit/Fitnesse and, in general, to test automation.
I am trying to use them from Eclipse.
I have several question about it:
is there a way to obtain the html tables that Fitnesse pass to Fit?
once I write several tests with Fitnesse, is there a way to call them several times from Java without clicking on the Test button of the wiki?
About passing objects from one table to another in a flow. I read about symbols but it seems that, in java, they works only with ColumnFixturewhile I would like to use DoFixture. how to do this?
Finally,is if there is any plugin for eclipse you suggest to use with Fit/Fitnesse?
Regarding you question 2: I would recommend using the JUnit integration (#RunWith(FitNesseRunner.class) to run the test page (or a suite) as a unit test from Eclipse. This also gives you the ability to debug inside your fixture code.
It takes a bit of configuration to get it running 'just right'. In my pre-packaged FitNesse I provide a unit test FixtureDebug where you only have to enter the test name (and you can also use that to run your tests on a build/continuous integration server).
I want to know that what's the difference between NG and Junit and which one is best for automation in Selenium Webdriver. Please explain with example
My recommendation is Testng because, click here the Advantages of Testng & Advantages of TestNG over Junit. also check this
On a rough note... TestNG is nothing but Junit along with some extra features like Reports and some annotations. If you are least bothered about the test execution reports, you can go with Junit. If you need html reports you can go with TestNG.
I just want to quickly ask, I found all over the internet and even here on SO, how Selenium IDE can create Java source files from what you are doing in browser. But all these sources result in some Unit Test. For Java I believe JUnit and some other are supported by Selenium IDE.
But I want to ask, why? I mean, if you still need to compile them before executing, why are Unit Tests used instead of just running the code and look if WebDriver throwns any exception? What is the advantage of using for example JUnit here? I know its mostly used this way, I just donĀ“t know why. Thanks.
Here's a couple of reasons off the top of my head:
1) You can hook your selenium tests into your build process (and hence your CI process).
2) You can use JUnit assertions.
3) You can build up multiple suites of JUnit tests (which can then be run in parallel).
I'm sure there's more but I guess it depends on the number of tests you have and the size of the project you are working on. If you're project already has a set of JUnit tests then it's quite nice to be able to write selenium tests without too much effort.
If you use Junit you can quickly recover from failures before starting a new test with the #before and #after annotations. You can also TearDown the tests with it. This also makes the tests more organized.
Not always you get an exception. Your application can handle an exception/user input/ etc. and navigate to different page then expected without throwing an exception - that can be easily verified by JUnit - assert expepected title of a page / presence of an element with actual values.