Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm familiar with jUnit, and heard TestNG might be a solution to some of jUnit's annoyences - e.g. its insistence to create a separate instance of the test class per test, thus forcing me to use static field for objects I want to reuse between tests.
(Let's say you agree with me that this is a drawback, and not turn this question to something it's not)
What I'm asking here, is what drawbacks does TestNG have, compared to jUnit? Why not use TestNG, assuming this is a new project and there isn't any migration cost?
I'm the creator of TestNG. I'm not going to weigh in since I'm obviously biased, but I'm happy to answer any question you might have about TestNG.
Andy: thanks for your comment. FYI (you probably already know that but maybe the original poster doesn't), there is a TestNG Eclipse plug-in (which I develop in parallel to TestNG).
I personally have not encountered any significant drawbacks compared to JUnit.
At the start of a new project, my team switched to TestNG and had no regrets. TestNG is more powerful and supports broader usage than unit tests.
Some tools support JUnit but not TestNG. These are tools that I have not yet needed. For example:
Google's CodePro Analytix supports generation of JUnit unit tests.
The Eclipse IDE for RCP development supports run/debug configurations for "JUnit plug-in tests."
Being a huge supporter of TestNG I still see it is treated as being number 2 by tools authors. Many tools and libraries support JUnit from the very beginning, but you have to wait till they also implement support for TestNG. This might be a serious drawback if you plan to use some latest buzzing technology.
Over the years situation improved a lot. For example this used to be an issue with Spring, Gradle, or Maven Surefire but is no longer a problem because they all support TestNG now. Also all IDEs are treating both frameworks equally.
So, make sure the other technologies you plan to use play nicely with TestNG. This is rarely a problem, but still better make sure of it ahead.
For me the biggest problem is an integration with spring.
I do not like to extend TestNg classes and write code like this:
#Test
#ContextConfiguration(locations = { "classpath:spring-test-config.xml" })
public class TestSpring extends AbstractTestNGSpringContextTests {
Because usually I have my own hierarchy of test classes.
This was the main reason why I stopped using TestNg.
I must agree that parameterized test was very attractive for me. But they can be easily replaced with junit data-provider.
https://github.com/TNG/junit-dataprovider/wiki/Getting-started
Related
I'd like to define two different suites in the same JUnit TestCase Class; one for behaviour tests and another for efficiency tests. Is it possible?
If yes, how? If not, why not?
Additional details: I'm using JUnit 3.8.1.
If I understand you correctly, you're trying to partition your tests. Suites, on their own, are not really the mechanism you need, rather it's JUnit's categories you need to investigate:
http://java.dzone.com/articles/closer-look-junit-categories
I've not used these as I've usually found the overhead of test partitioning too much effort, but this may work for you. I think TestNG has supported this concept for quite a while.
Also, if you're using Maven you get a partitioning of tests into unit and integration tests for free - check out the Failsafe plugin - which is good for separating tests you want to run quickly as part of every build from longer running tests.
This question already has answers here:
Running JUnit Tests in Parallel in IntelliJ IDEA
(3 answers)
Closed 5 years ago.
Is it possible to run junit tests in intelliJ in parallel? If so, how do i do this?
I set the "fork" parameter to class level and this didn't do anything - actually, it made everything a bit slower, so i'm unsure what "fork" does that is beneficial?
Is it possible to do this just using intelliJ, or do i need some fancy test framework and all the hoo-hah that that would involve?
Finally, assuming this is at all possible, can one control the number of forks or threads or whatever they want to call it?
UPDATE: somebody has linked to a question that might answer this. I looked at that question prior to posting - I'm unsure what that question really "answers". It simply says there is an issue tracker and that this issue has been implemented in intelliJ. I don't see how to implement it anywhere.
UPDATE: What does "didn't do anything" mean?: it just makes things slower, which isn't v. useful. I mean, maybe your tests run blazingly quickly and you want to slow them down to appreciate some Bach? That is cool. I just want mine to run faster, I'm fed up of Bach.
You can make use of the junit-toolbox. This is an extension library for jUnit that is listed on the jUnit site itself.
This extension offers the ParallelSuite. Through this you can create with nearly no effort an AllTest class that executes the tests in parallel. The minimum AllTest could look like the code below, using the pattern feature introduced with junit-toolbox.
#RunWith(ParallelSuite.class)
#SuiteClasses("**/*Test.class")
public class AllTests {}
This will create as many threads for parallel execution as your JVM reports via availableProcessors. To override this you may set the system property maxParallelTestThreads.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I often feel that after iterating over my code for a number of times I am left with functions or classes or other lines of code in general which made sense in the previous revision but are not very useful for the new revision. I know that a profiler can tell you what part of your code was called when you run your test cases? But how does one go about identifying what part of the code never got called to remove it so that whats left is more readable? For example, is there a quick way to know which functions in your code are not being called from anywhere and can be safely removed. It may sound like a trivial question for a small code base, but when your code base grows over the years, this becomes an important and not so trivial question.
To summarize the question, for different languages, what is the best approach to remove dead code? Are there any lanaguage agnostic solutions or strategies for this. Or does each language provide a tool for identifying dead code.
We normally program in Java or Python or Objective-C.
The term you're looking for is "code coverage" and there are various tools that will generate that information. You would have to make sure that you exercise every possible path through your code in order to be able to detect "dead code" with such a tool though, which is only possible with a really extensive set of tests.
Most compilers have some level of dead code detection, but that only detects code that cannot possibly be called, not code that will never be called due to program logic, etc..
edit:
for Python specifically: How can you find unused functions in Python code?
for Java: How to find unused/dead code in java projects, Java: Dead code elimination
for Objective-C: Xcode -- finding dead methods in a project, Cleaning up Objective-C code
For functions, try a global search on the function name, and analyze what you get. Dead code inside a function will usually be findable.
If you suspect a function of being unused, you can remove it, or comment it out, and see if what you've got still compiles.
This only works on functions that are unused because they are no longer called. Functionality that is never used because the control path through the code is no longer active is harder to find, and code analysis tools won't do well at finding it either.
You can use the code coverage report to find out the function which are not used or part of function which is never executed.
Based on the logic, you can treat them as dead code/unused code.
Popular code coverage tools that can be used:
C/C++: gcov & lcov
Python: Coverage.py
Java: JCov
Objective-C: xccov
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Languages like Ruby and Python are usually referred-to as open source, but what makes them so?
Is it an open-source compiler?, or interpreter or execution virtual machine?
If we're talking about the compiler, then would C++ be open source?
At the core, as others have observed, there really is no such thing as an "open source language". Only code can be open source in the strictest sense. So there can be open source compilers, runtimes, libraries, etc.
With many languages, however, the implementation (compiler/runtime) is almost inseparable from the language itself. This is the case with Ruby, Python, etc., where the language is effectively defined by its primary/original implementation. While there are other implementations of these languages, the primary implementation and the language are virtually interchangable. In such cases where the primary implementation is also open source, it makes some sense to refer to it as an open source languages, especially since such languages tend to have a community that is also almost entirely built around and friendly to open source software.
I don't think languages are generally considered to be open source, but rather the software implementing the language (whether it's a compiler or a virtual machine or whatever). It follows that a given language can have both open-source and non-open-source implementations. For example, there are many closed-source C++ compilers, as well as open source ones.
Perhaps one could make a distinction between a language that is controlled by a single entity (eg. C#) versus a language that is grown through community contributions (eg. Python or even Java).
I usually hear "open source language" applied to languages which are modified according to the wishes of the community. For example, Python has the PEP process, which allows anybody interested to alter the syntax / semantics of the language itself.
C and C++ are community-driven as well, though due to their age and ubiquity any changes require an incredible standardization effort. C++0x has been under design for years, and C has seen only 3 major versions (K&R, C89, C99).
Languages which are controlled by a single entity with very little community input, such as Java or C#, are usually considered "closed" regardless of the available implementations. There are GPL'd implementations of both the Java and .NET VMs available, but the language's evolution isn't community-driven. For an example of the grief this can cause, see efforts to add closures to Java.
I must admit I've never heard of a language being referred to as open source but I guess one way of viewing it is that the two examples you have given, Ruby and Python, are (AFAIK and I'm not an expert at all in either) both non-compiled languages whereas C and C++ are compiled.
So for client-side Ruby and Python applications you have to make the code available to the user since it gets interpreted at run-time whereas for compiled languages this is optional since only the compiled executable is required.
Of course on the other hand many Ruby and Python applications will be server-side, as part of the implementation of a website for example, and so the code is interpreted on the server and therefore never visible by the end user.
People often use the term "language" synonymously with the entire programming environment encompassing IDE, actual language, runtime environment/architecture and code libraries/frameworks. So when you say "open" I immediately think of Sun Microsystems releasing the code for the Java framework and VM as open source.
Then you have the likes of C#/.Net where the language, the core framework classes and the CLR spec are submitted to ECMA as a standard. Third parties such as Mono can implement those open, standardized components without having to license the technology and it could therefore be described as being open to an extent even though Microsoft's implementation is closed source (or only partially open anyway) and a commercial product. In Mono's case they implement some of the periphery framework classes that aren't standardised/open which is potentially a legal grey area.
Can we consider Open source language mainly in terms of GNU licences? Or should that be only the entity [comunity, company, etc.] driven criteria?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Are there any good PL/SQL libraries for JSON that you've worked with and found useful?
In PL/SQL, I'm having to tediously hand code the return of JSON values to JavaScript functions. I found one PL/SQL library for auto-generating JSON, but it doesn't do exactly everything I need it too. For example, I couldn't extend the base functions in the library to return a complex tree-like JSON data structure required by a JavaScript tree component I was using.
Note:
The system, which has been in production for 8+ years, was architected to use PL/SQL for the CRUDs and most of the business logic. The PL/SQL also generates 90% of the presentation layer (HTML/JavaScript), using mod PL/SQL. The other 10% is reported data done via Oracle Reports Builder.
#Geoff-
The system, which has been in production for 8+ years, was architected to use PL/SQL for the CRUDs and most of the business logic. The PL/SQL also generates 90% of the presentation layer (HTML/JavaScript), using mod PL/SQL. The other 10% is report data done via Oracle Reports Builder.
So, there isn't application code like you'd see in more modern, better architected systems. I do want to do things the right way, I just don't have that luxury given organizational constraints.
I wonder why you don't want to bring the data from Oracle into some application code and make JSON there?
Ouch - generating your interface in PL/SQL. You have my sympathy.
I've never done anything like this, but Googling found this page (which is also referenced from the json.org page).
A relatively new library called PLJSON (no slash) is on GitHub. We're using it in a pretty large project in production and have had no troubles with it at all. Parsing is a tad slow, but that is to be expected.
Disclaimer: I wrote it. If you find bugs or have suggestions, let me know.
In case that anyone is still interested in serving JSON using PL/SQL, I have just completed a PL/SQL data service framework named BackLogic. It is a full REST web service framework. It include a SQL utility to produce complex JSON structure from REF CURSOR, including the "complex tree-like JSON data structure required by a JavaScript tree component" mentioned in the original question, which the early PLJSON framework is not quite capable of doing.
I do see a bright future for PL/SQL in creating REST APIs. Until recently, the Object Relation Impedance has been taken care mainly by ORM frameworks in the middle tier. BackLogic solves this issue in the database, and thus is able to produce complex JSON structures needed by UI framework. Here is a link to BackLogic User Guide. You may find some non-trial examples in Section 5.3.