I use karma to run jasmine specs. Every time a file changes the tests are run. This is awesome but it would be even better if the previous test output would be removed from the terminal.
Is there a way to clear the terminal before tests are run in karma?
It is not supported. I like this idea though. I created issue #1004 to support this.
The issue #Sylvain has created is still open, but there is a plugin karma-clear-screen-reporter which does the job. Internally it uses the magic:
console.log('\u001b[2J\u001b[0;0H');
Alternatively you can also place this at the top of your test runner code to clear the console yourself.
Context
My answer is the same as #bluenote10
The difference is that I made some improvements to the package he posted and published it on my github:
Karma Clear Screen
Improvements
Improvement in the initial message.
Date of the update.
In addition to console.log('\u001b[2J\u001b[0;0H'); the spacing has been improved.
Related
I've written some test scripts & run them using the test runner. This has worked great, but unfortunately I didn't record the bugs at the time, via the test runner (just failed the steps and added comments).
When I review the Test Run Results I can create a bug for the Dev Team, but the Repro Steps box doesn't get populated with anything meaningful (see image1). I've spotted that the DevTeam can get to the test results via the 'Links' tab on the Bug, but it's a bit clunky:
However if I'd created a bug direct from the test runner, the bugs Repro Steps box gets populated with exactly what the DevTeam needs:
Does anyone know how/if I can generate the same nicely formatted test runner Repro Steps if I create a bug from the Test Results after testing? (I've got a few to do, so would prefer not to re-run the tests....)
You can write some code that will read test run content and copy paste this in bugs because this is just html in content of bug.
The best approach would be to create bug, and later on link test run to created bug.
I have been writing some code in WebStorm for a practice project. But the problem is, I have written some code today and the application seems to work fine, then tomorrow when I am writing some more code and the application is catching a bug which I am not able to debug, then I have to start all over again, which is pretty painful.
I would therefore like to save the code while it is working so that if required I can revert back to the last working version. I believe this is called version control and most people use GitHub for this, is it ?
I couldn't find a similar question. Maybe I am not using the correct keywords while searching.
I am using selenium webdriver to do automation of web application.(I am using eclipse)
In my test, I have written the code to login the page by credential, then click some links and go to a particular page.Now on that page i am filling fields through drop down and all and its not working.
So My question is if i changing my code to work with drop down,then to test this again i need to run test case from starting.Means again it it will login page will load and go through various links and then reach to that page.
So can not directly execute that steps only like we do in selenium IDE???
Again and again executing from starting is really screwing my time...??
Is there any way/shortcut?? Please suggest me.
Thanks
Selenium IDE is in-browser, it's then normal you can run at any step. But if your cookies have expired, you'll have to reauthent. It's not a Selenium problem, it's how websites work.
In your tests, you'll always have to start from scratch if your cases involve athent process, unless you manage to get a fine control over your cookies.
You can always make a quick http call to the website you want to connect to with HTTPClient for example, just to get the cookie back, then use it in webdriver with something like
driver.manage().addCookie(new Cookie("foo", "bar", "www.domain.com", "/", null));
then go to the page you need. Notice that this solution solves the Authent problem only, and does not control the state of the tested web-application (data previously posted, etc...).
At our company, we make an extensive use of selenium, and have a lot of tests relying on it, it's therefore a problem we know something about and we are aware of the frustation it can cause.
We use a pretty different solution to get a productivity boost on tests.
In fact, we're using a Groovy Shell-based solution which allows us to go back and forth while developping the tests and keep our browsers open. Groovy is a JVM scripting language that is really easy for a Java dev (almost all Java code is valid Groovy code) and it's really dynamic.
So you can download groovy, run groovy shell (groovysh is the command), then line by line you can launch and interact with the browser xhile your written code is saved to a buffer. When you've done with your test, export the code and put it in Eclipse. It's faster than restarting every time from scratch. Magic lines for starting with selenium are
groovy.grape.Grape.grab(autoDownload: true, group : 'org.seleniumhq.selenium', module : 'selenium-firefox-driver', version : '2.37.1')
import org.openqa.selenium.*
import org.openqa.selenium.firefox.*
driver = new FirefoxDriver()
driver.get("http://my-website.com")
From this point, the browser window is always open, and you develop right in groovy (or java). It's like a selenium-ide, but in groovy, and can be integrated in your developement workflow (but there is a bit of work to do)
This example works for Firefox (as you've probably guessed ;-)) but you can adapt it as you like. We have from this constructed a bunch of tools to develop our tests quickly and iteratively. We found this to be a great savior.
In the case you described, the tests will always return to step 1, therefore, you need to execute your automation suite from the beginning.
Tip for the future, separate your test cases to shorter ones (as Alexander suggested), so you if you need, you can easily use only the cases that needed and relevant to the module you currently working on.
There is nothing different answer..runs from first step...
And my kind advice is that to use a break point in eclipse at which u r guess of failing...and run the eclipse program in debug mode vth continuously pressing F6 key.
The excecution will be slowed and display will be step by step mode which u can easily trace the exact location at which u r code is breaking...
I use Eclipse IDE for my java projects and there are times in which I need to change some constants and test the effect of it.
But on change of the code I have to rebuild it which generally takes me 40 min and 5 more mins to start the server in debug mode.
So I am looking for some tools which make my task easy like cutting the rebuild time at least by 50 %.
You can put your constants out of the code. Put them in a properties file for instance. Then change your code to read the constants right from the properties file.
You will be able to build your code once and change the constants whenever you want.
If you're not already using it, you probably should look into setting up a continuous integration solution like Jenkins. You could automate builds to poll your code repository and monitor for changes, then run a suite of builds and tests with different flavors of constants to see the effect on your system.
I've managed to set up unit tests for my library in Xcode 4. I've performed builds with tests that I know will pass and fail (i.e. STAssertTrue(YES) and STAssertTrue(NO) ) just to make sure it's working. I'm using the default apple SenTest libraries following this document.
However, when my tests are running I'm getting this error in the build log :
An internal error occurred when handling command output: -[IDEActivityLogSectionRecorder endMarker]: unrecognized selector sent to instance 0x20310b580
To be clear, it's not affecting the running of the tests at all, just the output into the build window. All the tests run each time so I can tell a pass / fail by looking to see if the build succeeds or fails.
However, when my tests fail I can't find out which one fails because the output seems to stop when it gets to that error.
Does anyone have experience with unit testing / Xcode 4 / this error?
I just posted this on another thread, but I'm going the opposite direction for Xcode 4.
Please see my blog post exploring the topic, leave a comment if you think I'm wrong.
I realise it doesn't directly answer your question, but forget SenTestingKit and use GHUnit. It'll take you about 10 minutes to figure out (much more straightforward than OCUnit) and will save you a lot of headaches. IMHO, Apple should be shipping it with Xcode instead of OCUnit.
GHUnit can run your tests in a true application environment (with a GUI), or on the command line. It literally just drops into your existing project as a separate target.
https://github.com/gabriel/gh-unit