Git Product home page Git Product logo

cacert-frontendtests's Introduction

README

Clone this repo:

git clone git://github.com/Weltraumschaf/cacert-frontendtests.git

Next steps to get started

  1. Install Apache Maven

    • Debian Linux:

      $ sudo apt-get install maven2

    • Windows: [TBD]

    • Mac OS X: Maven is already installed.

  2. Install Sun Java JRE and JDK

    • Debian Linux:

      $ sudo apt-get install sun-java6-jre sun-java6-jdk

    • Windows: [TBD]

    • Mac OS X: Maven is already installed.

  3. Build the project (Make sure, you're in the project root directory, where the pom.xml file is located)

     $ mvn test
    

Maven will download all needed dependencies declared in the pom.xml file, build the project and execute all present unittests. If all went okay maven will terminate with the message

[INFO] BUILD SUCCESSFUL

and some runtime statistics.

Project Setup in your IDE

Netbeans

Recommended IDE for developing frontend tests is NetBeans because you just need to open the pom.xml and nothing else. With Eclipse the use of Maven is a bit more hassle. For getting the JavaDoc and sources of the dependeny open the project explorer in Netbeans and right click on the folder Dependencies and just clock the apropriate menue items.

Eclispe

[TBD]

How to write a test

In the project view (in Netbeans) you will see the directoy 'Source Packages' and 'Test Packages'. In the first one you will only find helper classes (e.g. for loading personas, create fixtures etc.). In the latter one you will find the the unit test classes (either for the helper classes or the frontent tests). As unit test framework JUnit is used. The frontent tests itself are contained in the package org.cacert.frontendtests. In this package you will add your tests. If you're not familiar with packages in Java read this.

Writing a test with JUnit follows nearly the same rules as in PHPUnit (because PHPUnit is a JUnit clone). You also need to extend a base class. But you will not extend the JUnits default TestCase but AbstractTestCase from the package org.cacert.frontendtests. This class provides helper methods for creating Webdriver instances, personas, fixtures or logged in sessions.

Some Java hints:

  • Attend the @Override annotation, if you overwrite a method. If you ommit this a compiler warning will be thrown.
  • No function keyword is needed for a method declaration, but a return type is required.
  • You can ommit this inside your scope, but keep in mind that local variables will shadow class fields.
  • Strings are double quoted "string", single quotes are characters 'c'!
  • Annotations are something similar to interfaces and so need to be imported.

An example for a test:

package org.cacert.frontendtests;

import org.junit.Ignore;

// You do not need to import AbstractTestCase because
// you are in the same package!

public class MyFirstTest extends AbstractTestCase {
	
	@Override
	protected void setUp() {
		// setup stuff
	}
	
	@Override
	protected void tearDown() {
		// teardown stuff	
	}
	
	@Ignore("Not ready yet")
	public void testSomething() {
		// your test code goes here	
	}
}

Some nice examples about annotations just found here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.