Execution Order Configuration with TestNG

Have you ever get confused when trying TestNG for the first time? especially when want to make a unit test with some execution order? I have :). So, I made a little example to encounter those problem. As we know, TestNG has some annotation to point our method/class and indicate when the test will running. Some of which are :

  • @BeforeSuite: The annotated method will be run before all tests in this suite have run.
  • @BeforeTest: The annotated method will be run before any test method belonging to the classes inside the <test> tag is run.
  • @BeforeGroups: The list of groups that this configuration method will run before. This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.
  • @BeforeClass: The annotated method will be run before the first test method in the current class is invoked.
  • @BeforeMethod: The annotated method will be run before each test method.

Continue reading Execution Order Configuration with TestNG

Integrate branch using Subversion (svn)

When I am in production and have issue that has big influence to the others, I always make a branch from trunk in order to not bother development other developer, if my issue has finished, I just have to merge my branch to trunk. then how? there are several way to through it, some of which are :

  1. Using visual diff/merge tool like meld
  2. Using reintegrate svn command.

For easily way, especially if your changes is not too much. You can using merge tool application that you can find in internet (remember if it’s paid application, the property is belong to respective owners). I am usually using meld, very easy to use. You can check the diff in file, folder and svn! 😀

Continue reading Integrate branch using Subversion (svn)

Simple Log4J Example Tutorial

Logging is very important in our project, it will record all activity include of info, error, debug, etc . With a good logging, we can trace when we get problem and fix it immediately. Now, I use Log4J as my logging framework, I will show you a simple Log4j example in this article . When you want to use Log4J, you have to make a file (whatever between .properties or .xml) that will be format your logging message. You can customize your logging properties, this is what I have :

#log4j.properties
log4j.rootLogger=DEBUG,stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%c{1}] %-5p %c:%L - %m%n</pre>

Continue reading Simple Log4J Example Tutorial

Using SuperCSV to parsing CSV file

I have wrote a tutorial about reading or/and parsing CSV manually in java here, but we have to think about simplicity. Now, I am using SuperCSV to parsing CSV file, I think it is more simple then we have to write a code manually. Let’s start coding.

We have to make CSV File, for an example, i make CSV with 4 row(3 content+1 header) and 4 column :


nim,name,department,dob
0811503721,Kus Andriadi,Teknik informatika,27/11/1989
0811502712,Rudi Gunawan,Sistem Informasi,28/03/1990
0711920192,Sherly,Sistem Komputer,03/05/1990

Continue reading Using SuperCSV to parsing CSV file

Copy row(s) into same table in MySQL

I have a litte trouble when I want to copy row from another row in same table with MySQL, after a little googling, I found the solution is very beautiful, we just have to add 2 command like below.


SELECT rowName FROM tableName FOR UPDATE;
UPDATE tableName SET rowName2 = rowName;

It is easy right? I post as a little article like this just to want help another people with same problem. So, hope this post is helps you, enjoy! 😀

Regards,