Sling server side Testing - unit-testing

I have deployed an OSGI bundle which is currently using a running FTP Server import some files , and saved the data in the Resource ( JCR / FS ) as provided .
For the time being considering JCR , I have written sling unit test bundle which returns test results after hitting the SlingJunitServlet . What is the best way i can invoke the test bundle from the client side ?

The SlingRemoteTestRunner allows JUnit tests that run as part of a Maven or other build to act as proxies for server-side tests that the SlingJUnitServlet runs.
See the ServerSideSampleTest example in the testing/sample/integration tests module.

Related

How to stop preloading modules in nosetst

The folder structure of my project is
base_dir
|__folder1
|__main.py
|__main_test.py
|__folder2
.
.
I have unittest written in main_test.py. The main.py uses pubsub client. The pubsub client is defined at the top as a module object. For testing I need to mock this object.
I used mock library to mock the client and it works fine(the client is successfully mocked). But when I run the same tests in github actions, the test fails. I as using nosetest to run tests in github actions. The nosetest loads all files together and results in pubsub client to be called.
I tried to move the import statements in the test itself, but still not useful.

How to run python backend testcases (using rest API) using AWS pipeline. Tests run successfully in my local machine

I am trying to run my testsuite with a testcase which has a post request using aws pipeline.
During build execution it fails with Timeout. It says "Max retries exceeded with url"
We do VPC configuration to run front end web testcases using devicefarm.
The same way, should we do any vpc configuration to run backend cases also?
If yes, what configuration and where can I do that.
Please share the infromation on this if you have any.
Thank you

Tell Travis to skip a test, but continue to include it in my main test suite?

I am using Django 1.8 and I have a management command that geocodes some items in my database, which requires an internet connection.
I have written a test for this management command. However, the test runs the script, so it also requires an internet connection.
After pushing the test to GitHub, my CI is broken, because Travis doesn't have an outside internet connection so it fails on this test.
I want to keep this test, and I'd like to continue to include it in python manage.py test when run locally.
However, is there a way I can explicitly tell Travis not to bother with this particular test?
Alternatively, is there some other clean way that I can keep this test as part of my main test suite, but stop it breaking Travis?
Maybe you could decorate your test with #unittest.skipIf(condition, reason) to test for the presence of a Travis CI specific environment variable to skip it or not. For example:
import os
...
#unittest.skipIf("TRAVIS" in os.environ and os.environ["TRAVIS"] == "true", "Skipping this test on Travis CI.")
def test_example(self):
...
If the external resource is an HTTP endpoint, you should consider using vcrpy to record and replay the HTTP requests/responses.
This way you can continue running the same test suite in different environments. It'll also speed this test up.

Karma/QUnit Unit Test External Site

I have a Portal application running on one port--http://localhost:10039. I am trying to unit test individual Ember.js applications, which are loaded into the Portal app via portlets.
What I'd like to be able to do is have those QUnit tests run against the full application, which is running on that other port I mentioned. However, Karma seems to not be fond of running the test suite on a port that isn't the same one on which the application is running.
For example:
test('Page loads in browser', function() {
visit('/login').then(function() {
ok(exists('#login-form'), 'Page loaded successfully');
});
});
... launches Karma successfully on port 9876, but yields...
Page loaded successfully# 42 ms
Expected: true
Result: false
Diff: true false
Source:
at http://localhost:9876/absolute/Users/me/Sites/app/node_modules/qunitjs/qunit/qunit.js:1933:13
at http://localhost:9876/base/tests/unit-tests.js:9:8
at isolate (http://localhost:9876/base/bower_components/ember/ember.js:36720:15)
at http://localhost:9876/base/bower_components/ember/ember.js:36703:16
at tryCatch (http://localhost:9876/base/bower_components/ember/ember.js:45817:16)
at invokeCallback (http://localhost:9876/base/bower_components/ember/ember.js:45829:17)
Is it possible to run my test suite on, say, http://localhost:9876, and have it run its tests against another website/port http://localhost:10039?
The closest I could come to an answer was Karma proxies, though the proxy seems to have no effect. Karma is still running its tests against links relative to its own port 9876.
I would like to add that I am open to other testing frameworks if this can only be done elsewhere--Jasmine, Mocha, etc.
Thanks!
karma is intended for running unit tests, so the code will be loaded in karma client (localhost:9876) and test cases executed there.
If you are planning to run certain end to end tests with your portal application, you could look into alternatives like selenium. In fact, your test above (testing for successful page loading) is a good fit with selenium.

How do you get the python Google App Engine development server (dev_server.py) running for unit test in GWT?

So, I have a GWT client, which interacts with a Python Google App Engine server. The client makes request to server resources, the server responds in JSON. It is simple, no RPC or anything like that. I am using Eclipse to develop my GWT code.
I have GWTTestCase test that I would like to run. Unfortunately, I have no idea how to actually get the google app engine server running per test. I had the bright idea below of trying to start the app engine server from the command line, but of course this does not work, as Process and ProcessBuilder are not classes that the GWT Dev kit actually contains.
package com.google.gwt.sample.quizzer.client;
import java.io.IOException;
import java.lang.ProcessBuilder;
import java.lang.Process;
import com.google.gwt.junit.client.GWTTestCase;
public class QuizzerTest extends GWTTestCase {
public String getModuleName() {
return "com.google.gwt.sample.quizzer.Quizzer";
}
public void gwtSetUp(){
ProcessBuilder pb = new ProcessBuilder("dev_appserver.py",
"--clear_datastore",
"--port=9000",
"server_python");
try {
p = pb.start();
} catch (IOException e) {
System.out.println("Something happened when starting the app server!");
}
public void gwtTearDown(){ p.destroy(); }
public void testSimple() {
//NOTE: do some actual network testing from the GWT client to GAE here
assertTrue(true);}
}
I get the following errors when compiling this file:
[ERROR] Line 21: No source code is available for type java.lang.Process; did you forget to inherit a required module?
[ERROR] Line 30: No source code is available for type java.lang.ProcessBuilder; did you forget to inherit a required module?
As you can see below, I basically want it to be the case that per test it:
Starts a datastore-empty instance of my GAE server
runs the test across the network, against this server instance.
Stop the server
Of course, report the result of the test back to me.
Does anyone have a good way of doing this? Partial solutions are welcome! Hacks are fine as well. Maybe some progress on this problem could be made by editing the ".launch" config file? The only important criteria is that I would like to "unit test" portions of my GWT code against my actual GAE Python server.
Thank you.
I would recommend creating an Ant target for this - take a look at this page for the full ant build file for GWT.
Then, as the first line of the testing target, add an execution task to start the server. Look here for exec docs.
Then set up that ant task in your IDE. This way you get the server running before your tests irrespective of where you run the tests from, and it can be integrated into your build process if you want.