The NUNIT automation scripts are NOT running from Task Scheduler - selenium

I am able to execute the NUNIT scripts using batch file. I am trying to run this batch file from Task scheduler to make it unattended and run regularly.
But bat file runs and provide output that window which is trying to perform automation is not opened.
Those are the parameters I'm using to launch the NUnit console:
cd C:\Program Files\NUnit.org\nunit-console
NUNIT3-CONSOLE D:\nunit\UnitTestProject1.dll --result="D:\nunit\TestResult.XML"
My code looks like this:
[Test]
public void TestMethod1()
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("www.oford.com");
}
Is there any way to run the batch files in unattended mode ?

I've started my first setup with the same approach, but some user privileges and Windows settings may interrupt at any time.
Is there any way to run the batch files in unattended mode ?
Yes, you can use a CI server. It is really to setup, free and powerful once you get the hang out of it. I would recommend Jenkins, because of its great community and vast resources (tutorials,plugins etc.). Configuring a basic job takes no more than five minutes. The reporting is also great.

Related

can't trigger a test of some appllication via Jenkins job

I am a beginner at the field of Devops.
I have created a simple web application (jsp), using 3 Jenkins jobs to store the code in GIT, to deploy the this app into Tomcat, and also to site-monitor this app (respectively).
Now, I have been trying - with no success -to automate a simple test with 2 verifications of my app functionality, using Selenium IDE and triggering it via Jenkins job (the fourth one in my project).
In order to perform it , I created the following job on Jenkins, with the needed plugin added (which is SeleniumHQ htmlsuite Run).
Here is the job:
https://i.stack.imgur.com/6Pm6a.png
The job running has failed,giving the following error which I cant handle.
When I run it, I get the following error :
https://i.stack.imgur.com/hXGmI.png
Any help would be very appreciated
Just tick Delete workspace before build starts box under Build Environment stanza
If you don't have the option in your Jenkins job configuration - make sure that Workspace Cleanup Plugin is installed
If you're running your Selenium tests via Jenkins Pipeline - all you need to do is to put cleanWS() directive somewhere in your pipeline code or Jenkinsfile

Display selenese-runner results in Jenkins

As I am implementing an automated way to GUI test our webapplication with selenium I ran into some issues.
I am using selenese-runner to execute our Selenium test suites, created with Selenium IDE as a post build action in Jenkins.
This works perfeclty fine, as the build fails when something is wrong, and the build succeeds if all tests are passed. And the results are stored on a per build basis as HTML files, generated be selenese-runner.
My problem is however, that I seem to be unable to find a way, how to display these results in the respective jenkins build.
Does anyone have an idea how to solve this issue. Or maybe I am on the wrong path at all?
Your help is highly appreciated!
I believe the JUnit plugin should do what you want, but it doesn't work for me.
My config uses this shell script to run the tests (you can see the names of all my test suites):
/usr/bin/Xvfb &
export DISPLAY=localhost:0.0
cd ${WORKSPACE}
java -jar ./test/selenium/bin/selenese-runner.jar --baseurl http://${testenvironment} --screenshot-on-fail ./seleniumResults/ --html-result ./seleniumResults/ ./test/selenium/Search_TestSuite.html ./test/selenium/Admin_RegisteredUser_Suite.html ./test/selenium/Admin_InternalUser_Suite.html ./test/selenium/PortfolioAgency_Suite.html ./test/selenium/FOAdmin_Suite.html ./test/selenium/PublicWebsite_Suite.html ./test/selenium/SystemAdmin_Content_Suite.html ./test/selenium/SystemAdmin_MetaData_Suite.html
killall Xvfb
And I can see the result of the most recent test (you can see the name of my jenkins task folder)
http://<JENKINS.MY.COMPANY>/job/seleniumRegressionTest/ws/seleniumResults/index.html
Earlier tests are all saved on the Jenkins server, so I can view them if I need to.

How to get TestNG results on jenkins while building?

I'm trying to get tests results while the job is building.
When we run tests suite by eclipse we get tests results from TestNG viewer while running the suite, I want to get the same viewer or similar in Jenkins to know the current status of the build before finish.
I mean this in TestNG Viewer:
Results of running suite TestNG viewer
Thanks All :)
AFAIK it is not inbuilt as part of any plugin. But there are couple of options that you can try.
Write results to a database in the IInvokedMethodListener after implementation. Build a ui over the database.
Maintain a datastructure of results , do console out of summary(if you are the only one who needs to know the results) on jenkins in test listener or method listener of the results based on the frequency at which you need to know results. Or you can start of a parallel script which parses the consoleText either as a shell or a separate utility doing curl on the consoletext.

groovy (java): exec() do not detach from process (Intellij IDEA vs Maven+TestNG)

I have Groovy Maven2 test project with TestNG and Surefire plugin enabled.
I want to launch external process (*.cmd file which start some *.exe file) in last test method, finish my tests and left process running after tests.
I tried the following codes to do it:
1 attempt
def builder = new ProcessBuilder('cmd','/c <name>.cmd')
builder.directory( ( new File( <path_to_working_directory> ) ) )
builder.start()
2 attempt (with and without start cmd option)
Runtime.getRuntime().exec( "cmd /c start <name>.cmd", null , ( new File( <path_to_working_directory> ) ) )
3 attempt
( new AntBuilder() ).exec(
dir: "<path_to_working_directory>",
executable: "<name>.cmd"
)
Where .cmd is:
set path=<path_to_execFile>;%path%
start <execFileName>.exe
When I launch each of these codes from Intellij IDEA via 'Run' functionality (Alt+Shift+F10) codes execute successfully, process started and run after test finishes.
When I launch each of these codes both from Intellij IDEA Maven task, clean Maven installation (and even Maven task from Jenkins) process started successfully but test remains running. I need to kill it manually. When I kill test process (Maven process) manually my launched external process continue to work as I expect.
This hung test process is my headache for the moment.
I looked through a lot of materials but didn't find any root cause, fix and even workaround for this issue. I see that all my attempts (perhaps, except of AntBuilder()) create deattached processes. I suppose that this can be connected with JVM settings. But I coudnl't find to which one.
Also, I tried
"full command to run my cmd".execute()
but it didn't help me too.
Could you please help me resolve the issue?
Thanks In Advance!
So, I do not see any answers for my issue here. But I have some updates.
I found that I can use PsExec tool instead of direct cmd calling:
def builder = new ProcessBuilder( 'psexec', 'cmd', '/c', '<name>.cmd' )
builder.directory( ( new File( <path_to_working_directory> ) ) )
builder.start()
And this code works fine when I launch it from clean Maven only (not from Jenkins): process started, Maven task completes successfully, the process continues to run.
But during execute this code as part of some Maven2 Jenkins task I faced to issue again: psexec started but Jenkins task is running and my process does not started before I terminate Jenkins task manually.
To avoid this issue I created simple additional Groovy service script I launch in listen mode (and Writing a TCP Server) on target machine manually during initial machine preparation. This script is running on machine always.
I send to this listener name of command file to execute from my test I launch from Jenkins and it executes all cmds successfully: processes start, Jenkins task completes successfully, processes continue to run. I use processbuilder inside this listener.
For name sending I use simple socket (Writing a TCP Client)
Also, I found how to detach child from process tree on win32?. But for me system my way looks more Groovy I think.

Pax Exam tests fail occasionally

I am testing CXF REST services in Karaf using Pax Exam. The tests almost always run without a hitch on my machine. When run in Jenkins (under Maven build) they typically fail. The failures seem random and unpredictable. The error I receive during the failure deals with attempt to run a Karaf command. The commands are executed by the following snippet:
def byteArrayOutputStream = new ByteArrayOutputStream();
def printStream = new PrintStream(byteArrayOutputStream);
CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
commandSession.put("APPLICATION", System.getProperty("karaf.name", "root"));
commandSession.put("USER", "karaf");
commandSession.execute(command)
These are the commands I am trying to execute in the tests setup method:
'features:addurl mvn:org.apache.cxf.karaf/apache-cxf/2.7.2/xml/features', 'features:install http', 'features:install cxf'
This is the exception:
org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: features:addurl
Apparently occasionally Karaf does not start correctly and cannot process these commands. The error like this one happen randomly in different tests on different Karaf commands. On my machine they are more likely to happen if the machine is under load.
What may cause Karaf to behave in such a manner? How to prevent these errors from happening?
Thank you,
Michael
There is is also pax-exam-karaf, it also has a feature installer which is usable from the configuration. If you want to stick to the "manual" installation you shoul make sure the features service is installed beforehand. For example let the service be injected.