JUnit test in Kotlin - junit

Warning: I'm a huge noob to TDD and Kotlin.
I've found good code snippets on the web for writing JUnit tests in Kotlin, but when I copy and paste, IntelliJ does not automagically import kotlin.test.* or org.junit.Test. Typically in Eclipse, when I copy and paste code snippets like this, the IDE can figure out where these libraries are in my underlying java install. Figured Kotlin/IntelliJ would be the same.
In the below screenshot, any idea why I cannot import test libraries? Do they need to be added explicitly to my path? Do I need to put these under a test, rather than the src folder?
Thanks

JUnit isn't in your project classpath, so IntelliJ can't find it's packages.
Follow the steps outlined in this answer: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project, choosing libraries and then junit.

Related

Java decompilers that support renaming and other IDE features

I've been trying my hand at decompiling dex and jar files with a few decompilers. So far the best one I've used is jadx, and it also comes with a GUI. However, it seems to be read only. Is there a decompiler that allows me to rename variables/methods/classes for obfuscated code, as well as other more advanced IDE features such as find when a class/method/variable is called/accessed?
In my opinion the best way to do that is to decompile the JAR and then import the code in a IDE of your choice.
If you use IntelliJ IDEA you can create a new project, import the JAR as an external lib, and then use the built-in decompiler. You can then set breakpoints etc.

TestNG equivalent of running NUnit tests with a .dll file on NUnit UI

So far I have been using eclipse to run testng tests, which requires me to code out a small program that includes a testng project; however this means every time I need to setup someone else's machine I have to pass alone the source codes so that they can run on their own eclipse.
I am sure it is not the best practice as when I was doing it in C#, I can build a .dll file to be imported in nunit's UI and I can execute the test from the nunit's UI. In this case I will just need to feed new users with the .jar or w/e file and tell them to use that UI tool to execute the tests. My questions fall below:
1) Are there any equivalent of nunit UI's for testng?
2) If so, how can I generate a .jar or w/e file of the testng project?

importing libgdx test projects Error

Problem
I downloaded the libgdx-master.zip library and unzipped it, then tried to import android tests project in eclipse, doing so gives an exclamation mark which is not a unique error but problems i am facing are below.
I did following to sort it out, but did not work for me
Created libs folder in the project and copied all the jars in that
In project properties i added the jar files that come along libgdx-master.zip libray
Cleaned the project
That is what i do when ever resources conflict or exclamation mark comes in my project
Errors
In the imports: The Classes this test project uses from libgdx-master libray
In Project Properties->Java build-> Project-> some missing projects appear
I searched a lot about importing the test projects present in this library, but, can only found creating new project to use this library
What i aspect from the community
Importing test projects from the library libgdx-master, any
tutorial link/guide you used yourself, i tried a lot.
Any one who used this library could answer more properly
what rating/ranking would you give to use this library for android board game development
I know how to import the projects and link the resources, but, in this specific case it did not work for me, if you please answer specifically, i would be grateful.
At the the end i would like to thanks who showed patience to read this.

IntelliJ 10/11 AutoComplete broken with SWC dependencies from SWF Project

I am working on setting up a project for some developers and helping them componentize some of their code into a swc. I have created an Ant build process for them, but when setting up dependencies in IntelliJ's Flex Facets we are seeing that code that is referenced from the Libraries is not autocompleting nor is it letting us step into classes accross libraries. I am sure this works as I have done it with a Maven setup before. I just wonder if there is some setting I am missing when doing ti manually as these guys are not willing to go the route of Maven yet.
Here is a quick screenshot of our test SWF that depends on two SWC libraries:
Notice that in this sample class the code that lives in the client-core project does not show up as code completed (it's red) but it compiles fine with Ant.
Any ideas as to what we are doing wrong here?
answered in InteliJ IDEA forum: http://devnet.jetbrains.net/message/5447354#5447354

Recompiling sources with a test specific jar

I have a multimodule project that is dependent on a rather large thirdparty library/apis. It is not possible to run automated junit tests with the actual library, since the apis interact with a system external to the management of the dev environment. As a workaround, we created classes that mocked the interfaces/apis so that we could do junits. We use eclipse as our IDE for development, so to run junits, we simply move the jar up higher in the classpath, recompile, run our junits, and everything works great.
Looking for a similar solution now that we are moving to Maven. Basically, after building our code, need to rebuild all of it again using the mock jar to run junit tests. This goes across all modules of the application. I tried adding the jar in the test scope, but that is only used for compiling the test classes; the sources classes are still compiled with the real jar. However, it fails at runtime since our mock jar does not match all signatures of the real jar (so a hot swap of the jar doesn't work; making all signatures match would be large undertaking). So the source needs to be recompiled with the jar.
So it appears there are two options:
1) Make a standalone test module that somehow pulls in all the source modules code and recompiles it using the mock jar and runs the tests or
2) Each module creates a testjar in addition to its installable jar that compiled with the mock jar, is then used by the dependent modules during the test phase.
Please advise. Any examples of how to do either of the above would be greatly appreciated.
Check out this link. I think it has what you need. You can handle this using two maven profiles. According to this you can have different dependencies for each profile.