Hudson – Tool to build/test your project
I started a new project and now I am using new tool, One of them is Hudson . Hudson is a tool to build easy and simple using. The tool is made in Java.
The dependencies basically is Java.
How to install the Hudson:
$ apt-get install sun-java6-jdk sun-java6-jre sun-java6-bin
or
visit the : http://www.java.com/en/download/linux_manual.jsp?locale=en&host=www.java.com:80
On Debian-based distributions, such as Ubuntu, you can install Hudson through apt-get.
1.Add the following line to your /etc/apt/sources.list:
$ deb http://hudson-ci.org/debian binary/
2.Update the APT index
$ sudo apt-get update
3.Install Hudson:
$ sudo apt-get install hudson
For execute the Hudson:
1. If you using the .war. If you installed the packages .deb,go to the next step.
$ java -jar hudson.war
2. Open the browser and type:
http://localhost:8080/
3. For create a new job is very simple.
3.1. Click on ” New Job “
3.2. Select the option , im my case I choose the “Build a free-style software project”
3.3 Select the options , wirte scripts and save.
State Machine
Hi,
A state machine with three states, state1, state2 and state3. The state machine is controlled by three QPushButton; when the button is clicked, the machine transitions to another state. Initially, the state machine is in state state1.
main.cpp
1 #include <QtGui>
2 #include <QApplication>
3 #include <QVBoxLayout>
4 #include <QPushButton>
5 #include <QStateMachine>
6
7
8
9
10 int main ( int argc, char **argv)
11 {
12 QApplication app(argc, argv );
13
14 /* Set the name application */
15
16 app.setApplicationName(“EX_State”);
17
18 /* Here created a window */
19
20 QWidget *window = new QWidget;
21
22 /* Here created the buttons */
23
24 QPushButton *button1 = new QPushButton (“Estate 1”);
25 QPushButton *button2 = new QPushButton (“Estate 2”);
26 QPushButton *button3 = new QPushButton (“Estate 3”);
27
28 /* Here created the Layout */
29
30 QVBoxLayout *vbox = new QVBoxLayout;
31
32 /* Here the buttons are added in the Layout */
33
34 vbox->addWidget(button1);
35 vbox->addWidget(button2);
36 vbox->addWidget(button3);
37
38
39
40 window->setLayout(vbox);
41 window->resize(480,600);
42
43
44
45 /* The state machine is created */
46
47 QStateMachine machine;
48
49 /* State are created */
50
51 QState *state1 = new QState();
52 QState *state2 = new QState();
53 QState *state3 = new QState();
54
55
56
57 state1->setPropertyOnEntry(button1,”geometry”,QRectF(0,0,100,100));
58 state1->setPropertyOnEntry(button2,”geometry”,QRectF(100,100,200,200));
59 state1->setPropertyOnEntry(button3,”geometry”,QRectF(300,300,150,150));
60
61 state2->setPropertyOnEntry(button1,”geometry”, QRectF(380,1,100,210));
62 state2->setPropertyOnEntry(button2,”geometry”, QRectF(1,99,100,310));
63 state2->setPropertyOnEntry(button3,”geometry”, QRectF(200,200,100,410));
64
65 state3->setPropertyOnEntry(button1,”geometry”, QRectF(10,10,470,20));
66 state3->setPropertyOnEntry(button2,”geometry”, QRectF(10,300,470,20));
67 state3->setPropertyOnEntry(button3,”geometry”, QRectF(10,570,470,20));
68
69
70 state1->addTransition(button1, SIGNAL (clicked()), state1);
71 state1->addTransition(button2, SIGNAL(clicked()),state2);
72 state1->addTransition(button3, SIGNAL(clicked()),state3);
73
74 state2->addTransition(button1, SIGNAL (clicked()), state1);
75 state2->addTransition(button2, SIGNAL(clicked()),state2);
76 state2->addTransition(button3, SIGNAL(clicked()),state3);
77
78 state3->addTransition(button1, SIGNAL (clicked()), state1);
79 state3->addTransition(button2, SIGNAL(clicked()),state2);
80 state3->addTransition(button3, SIGNAL(clicked()),state3);
81
82 /* States are added in state machine */
83
84 machine.addState(state1);
85 machine.addState(state2);
86 machine.addState(state3);
87
88 /* Set the state initial for the state machine */
89
90 machine.setInitialState(state1);
91
92 /* Start the state machine */
93 machine.start();
94
95 window->show();
96
97 return app.exec();
98
99
100 }
The Simple Test
I am learning a few of QtTest and I am showing the simple and little test for QtDate . The test verify if the date is valid and compare the actual date.
== test.cpp==
1 #include <QtTest>
2
3
4
5 class testDate: public QObject
6 {
7 Q_OBJECT
8
9 private slots:
10
11 void testValidity();
12 void testCurrentDate();
13
14 };
15
16 /* Here the test for verifying if the date is Valid, can you change the Day for plus 31 and the Mo nth plus 12 */
17 void testDate::testValidity()
18 {
19 QDate date (2009, 04, 33);
20 QVERIFY(date.isValid());
21 }
22
23
24 /* Here the Date is compared with the actual Date */
25 void testDate::testCurrentDate()
26 {
27
28 QDate date, date2;
29 date.setYMD(2009, 4, 22);
30 date2 = QDate::currentDate();
31 QCOMPARE(date, date2);
32 }
33
34
35
36
37 QTEST_MAIN(testDate);
38 #include “test1.moc”
==
QVERIFY ( condition )
The QVERIFY() macro checks whether the condition is true or not. If it is true, execution continues. If not, a failure is recorded in the test log and the test won’t be executed further.
QCOMPARE ( actual, expected )
The QCOMPARE macro compares an actual value to an expected value using the equals operator. If actual and expected are identical, execution continues. If not, a failure is recorded in the test log and the test won’t be executed further.
References: