hi guys j

is there a way on how to analyze java snippet of codes, like for loops, while loop to check to see what will be the result of it, whether it would run, what results, or if it would give you any kind of syntax error, run time error or logical error,
do you have that facility on this site available.

Unit testing is a means to test the "smallest units" (methods) in your code. You either provide all the parameters, or you create mocks for services required by your method (if you search for this, it returns result A, if you search for that, it returns result B, if you search for yet something else, it 'll throw an exception, ...)

JUnit

Here are a few links sure worth reading through:
http://stackoverflow.com/questions/3258733/new-to-unit-testing-how-to-write-great-tests
https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests

you can write tests that cover your entire code, meaning you'll be able to test every possible scenario of the application before it's even used, and thus prevent any mistakes.

At a far far simpler level I have a NetBeans project that looks a bit like

   class test {
      public static void main(String[] args) {
         // put code to test here
      }
    }

so when some interesting bit of code appears on DaniWeb I can just paste it in there and compile/run/debug it with roughly zero effort.

I have a similar one that creates and dsiplays an empty JFrame, so I can check out Swing code quickly.

This article has been dead for over six months. Start a new discussion instead.