JC Web Concepts

Using TextMate Over Eclipse?

So as doing automation as my everyday job I find myself in the Eclipse IDE all day. Now there are lots of advantages of using Eclipse but I hate that it is so slow. One day I got so frustrated that I decided to try using my favorite editor TextMate, to do my job. So I thought I would discuss both applications and what I like and disliked. Please post comments or reply to me on twitter with your comments.

Eclipse
This is a very popular tool that a lot over developers use for Java programming. It has a lot of features to autocomplete method names. Code refactoring is another nice tool that it has. If you are working with Maven and TestNG it is also supported as well. The two biggest issues with Eclipse is that it is slow and a big resource hog. Other than that it is not that bad.

TextMate
This is a popular text editor for the Mac. With its bundle support it is a very nice tool to use. TextMate does have bundles that cover Maven and some TestNG. The issues that I come up with is that autocomplete is limited in TextMate. If I am referencing a page object and I want to call a method of that page object, there is no autocomplete for that. This is the biggest reason why I have trouble using TextMate as my editor for Selenium code. I like TextMate cause it is small and is not a resource hog.Again if I am missing something with TextMate, please let me know. I would love to be able to get rid of Eclipse all together.

Commenting Your Code

One of the things that a lot of people over look when coding is adding comments to it. Everyone should comment their code and there is no reason why you do not need comments. Even if you are writing something for your own use you still should comment on that code. Here are a few reasons why you should comment:

  • Makes reading code easier.
  • Helps someone understand your code when they are new or have not read it recently.
  • It shows that you understand the standards of coding

Commenting is one thing that I myself find that I lack but I work on it to make sure its there. I am not stating that you have to comment every line but you should try to keep it to every 4 to 5 lines. Be brief in your comments and get to the point. So look at your code and see if there are comments there. If not you should start to add some. I hope this helps.

Moving Your SVN Repo

One of the things that I sometimes have to do is move an SVN repo to another server or you just want to back it up. This tutorial will show you how to do this.

svnadmin dump /pathToYourRepo > reponame_dump
Example: svnadmin dump /var/svn/mywebsite > mywebsite_dump

So now you want to go move this file to your new server and create your subversion repo. Make sure you use the same name as the old one. Go to folder where you uploaded your dump file to and do the following:

svnadmin load /pathToYourRepo < reponame_dump
Example: svnadmin dump /var/svn/mywebsite < mywebsite_dump

So there you go. In this tutorial I did not include setting up the subversion server cause I made the assumption you know how to do this since you already have an SVN repo setup.

TextMate

As a web developer one of the things you look for is a good editor to use to code your projects. When I was using Windows I would use and app called Notepad++ which was an awesome editor. When I switched to a mac finding an editor was a little difficult. Well I believe I have found it. TextMate is the app that had what I was looking for. As I am still learning it I have fallen in love with this application. It is not free but it is well worth it. I am even writing this blog post in it and able to upload it right to my blog all from TextMate. It is not free but it is well worth it. All the plugins which are called bundles make it easy for you to customize the app to you liking.

In a future post I will have some video on how to do things in TextMate. So stay tuned and thanks.

Bluefish IDE Editor

Well as a PHP, HTML, CSS, and jQuery designer one of the things I have been looking for is a good lightweight text editor. I have used many different types of editors and not found the right one. When I programmed in Windows I loved Notepad++, but there is no Mac/Linux equivalent. The editors that I have used in the past are as follows:

  • NVU
  • Dreamweaver
  • VIM
  • Eclipse
  • Bluefish

    The last editor I was and still will use is VIM. There is times I just want to click somewhere to move my cursor, I.E. Being lazy. I really like bluefish cause it is very lightweight and fast. Eclipse and Dreamweaver just are too slow for me. Bluefish will work in Mac, Linux, and Windows. The best thing I like about it, is it is free. So take a look at them, post some comments about what you think is the best. Maybe you have one that I just have not seen.

jQuery Basics Tutorial

jQuery is an upcoming/hot thing right now when it comes to web development. To me jQuery is slowly taking over flash. There are lots of things I can do in jQuery that I would have programmed in flash for. Before you kill the messenger there are things out there that flash can do that jQuery can’t. So let me post the source code for the tutorial and below that you can watch in video as I explain.


  
      jQuery Basics Tutorial
        
        
        
    
    
        
        
        
John Smith Developer
Greg Smith Owner
Michelle Smith Web Developer
Scott Smith IT Administrator
Michelle Smith Web Developer

Selenium Automation With TestNG

I wanted to start off with a simple tutorial that shows you how to write some simple automation scripts. Basically you write Selenium scripts that will test/verify information on a webpage. Example would be lets say you have a webstore that has a shopping cart. You might want to write automation that goes thru purchasing something to make sure it is working. So here is the video and below that I will have the script as well.

package com.jcwebconcepts.tutorials.basics;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class SimpleBrowserTests {
    private String appURL = "http://www.jcwebconcepts.net";

    @Test public void openMyBlog() {
        FirefoxDriver driver = new FirefoxDriver();
        driver.get(appURL);
    }

    @Test public void searchGoogle() {
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
        driver.findElementByName("q").sendKeys("Apple");
        driver.findElementByName("btnG").click();
    }
}

Setting Up Eclipse

I wanted to talk about how to setup your Eclipse IDE to work with Selenium, Maven, and TestNG. For those who do not know what those are you can click on the link to learn more. I will be making some more posts/tutorials on how to use these items. Eclipse can run on Mac, Linux, and or Windows. You need to have Java installed and if you want to work with SVN then you need the command line SVN client. From the video below here is the list of the sites that you will need to add to Eclipse:


    
    
    
    
        org.apache.maven.plugins
        maven-surefire-plugin
        2.4.3
        
          
              
                  app.env
                  ${app.env}
              
          
        
            **/TestUtilities.java
        
        
    
    
        org.apache.maven.plugins
        maven-compiler-plugin
        
          1.5
          1.5
        
    
      
          org.apache.maven.plugins
          maven-checkstyle-plugin
          2.2
          
              checkstyle.xml
              true
              true
              true
              true
          
          
              
                  validate
                  
                      check
                  
              
          
      
    
    
    
    
    net.sf.jacob-project
    jacob
    1.14.3
    
    
      org.springframework
      spring
      2.5.5
    
    
      org.springframework
      spring-webmvc
      2.5.5
    
    
      org.springframework
      spring-test
      2.5.3
    
    
      javax.servlet.jsp
      jsp-api
      2.1
    
    
      log4j
      log4j
      1.2.14
      runtime
    
    
      javax.servlet
      servlet-api
      2.4
    
    
      oracle
      oracle
      14
      test
    
    
    org.testng
    testng
    5.11
    jdk15
    test
    
    
    org.seleniumhq.selenium
    selenium
    2.0a2
    
    
    org.seleniumhq.selenium
    selenium-server
    2.0a2