Tec&Cult
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Tec&Cult

Technologie et Culture
 
AccueilAccueil  PortailPortail  GalerieGalerie  Dernières imagesDernières images  RechercherRechercher  S'enregistrerS'enregistrer  Connexion  
Sujets similaires
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Derniers sujets
» Que faire à Paris le week-end du 15 août ?
Write a JUnit testcase in Java EmptyJeu 11 Aoû - 11:20 par Admin

» T-shirt Mec de Paname
Write a JUnit testcase in Java EmptyMer 3 Aoû - 17:04 par Admin

» dating web site uk dating free parent single
Write a JUnit testcase in Java EmptyMer 3 Aoû - 10:56 par Invité

» rsvp dating website seeking bisexual
Write a JUnit testcase in Java EmptyLun 1 Aoû - 2:08 par Invité

» dating french woman gay bottom seeking tops
Write a JUnit testcase in Java EmptyDim 31 Juil - 21:59 par Invité

» dating philippine woman man seeking wealthy woman
Write a JUnit testcase in Java EmptyVen 29 Juil - 12:51 par Invité

» dating lesbian n r cacee cobb dating lachey nick
Write a JUnit testcase in Java EmptyVen 29 Juil - 3:17 par Invité

» single dating chat room relationship dating advice
Write a JUnit testcase in Java EmptyJeu 28 Juil - 0:21 par Invité

» скачать порно тетя скачать порнофото семейное
Write a JUnit testcase in Java EmptyJeu 21 Juil - 14:34 par Invité

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Forum
Partenaires
Forum gratuit


Tchat Blablaland
Le Deal du moment : -14%
Apple MacBook Air (2020) 13,3″ Puce Apple M1 ...
Voir le deal
799 €

Partagez | 
 

 Write a JUnit testcase in Java

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Admin
Admin


Messages : 156
Date d'inscription : 20/05/2010

Write a JUnit testcase in Java _
MessageSujet: Write a JUnit testcase in Java   Write a JUnit testcase in Java EmptyJeu 23 Juin - 16:04

http://toptech.geekaddict.net/
Write a JUnit testcase in Java
JUnit is a popular testing framework. This guide shows how to write a JUnit test.
A class to be tested:
class Calculator {
public int add(int i, int j) {
return i + j;
}
}

Rules for writing a JUnit testcase:
the test case needs to extend junit.framework.TestCase base class
the name of the Test methods must begin with "test" (eg: testAdd())
the test methods must not take any arguments (eg: testAdd(String x) is wrong)
the test methods need to have void return type
the test methods must not throw any exceptions
Our testcase:
import junit.framework.TestCase;

class CalculatorTestCase extends TestCase {
public void testAdd() {
try {
Calculator calc = new Calculator();
int result = calc.add(1, 2);
assertEquals(result, 3);
} catch(Exception e) {
fail();
}
}
}
Revenir en haut Aller en bas
http://toptech.geekaddict.net
 

Write a JUnit testcase in Java

Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Tec&Cult :: Informatique :: Java :: Tutoriel-
Sauter vers: