I am using google cloud function written in javascript to do the transformation of an event received from a pub/sub topic and publishing it to another pub/sub topic.
Function is working perfectly fine. My question is around testing.
I have been following googles guide to write unit and integration tests.
Unit tests are working fine. I am using Jest framework.
I am not sure how to complete Integration tests.
I am following this link
Cloud function is publishing to another topic at the end. How do I test this integration test.
I am using functions-framework as suggested by google to do the integration test.
Does anyone have any idea how do I inject mock implementation for pub/sub publishing part
Integration test looks similar to this
Related
I want to write the business logic of my CodenameOne application using JUnit 5. But when I try to run any unit test in Intellij, the simulator is started with the app instead of the unit tests.
Did anybody figure out how to setup Intellij such that the unit tests can be run without triggering the Ant build?
Codename One has its own unit test API and test recorder, generally you should use that for your testing as it allows you to test everything including the GUI.
See this for further details on using the testing framework.
You could probably use JUnit for the pure business logic but I'm not sure what benefit it would provide.
In the AWS SDK, EC2 instances can be launched programmatically via the AmazonEC2Client. Does GCP in general or Compute Engine specifically just offer the CLI-based gcloud command for the equivalent operation? Or can GCE instances be controlled from Java/Python/Go/etc as well? Which SDK exists for those languages and where are the examples & docs for this?
I am looking for the equivalent of this in the GCP world:
client = new AmazonEC2Client(credentials);
client.runInstances(new RunInstancesRequest())
You're looking for the Google Cloud Client Libraries, of which gcloud-java is the Java implementation. There are also Client Libraries in Go, Node.js, Python, and Ruby.
Under the covers everything in Google Cloud is available via an API, so even if there isn't a client library for what you're trying to accomplish, it can be done programmatically by calling the API directly.
The documentation on launching instances has an API tab that shows both Client Library and REST API examples.
Looks like this is still in alpha but it is available on Github: here and here. There is an example for starting GCE instances in the java-docs-samples project.
I'm able to run simple Selenium Junit Test case from Silk Central test management tool. Now I want to design selenium framework to work with Silk Central. Please let me know if any one is using silk central to run their selenium scripts designed in junit.
Please find my questions below:
1.How to automatically add the captured screenshot via Selenium webdriver to Run details section of Silk central Junit Test case.
2.How to automatically add my own custom defined log4j file to Run details section of Silk central Junit Test case.
Please help me guys i'm unable to find the answers.
Silk Central provides several parameters and information as a Java System property.
In your case, you need the value of the system property #sctm_test_results_dir in your JUnit test. The system property provides the path information of the folder, where all result files are collected after the run was finished.
With this folder information available in your JUnit test, you can place all your files there and they are automatically collected by Silk Central and are available in your test results.
(There are more parameters available for tests, just check the documentation topic 'Accessing Silk Central Parameters through Java System Properties')
BTW, we have releases a blog post on Selenium and Silk Central this week, just for your information: https://community.microfocus.com/borland/test/silk_central/b/weblog/archive/2015/06/10/test-management-for-selenium-tests-with-silk-central.aspx
i have been given a project to write test cases for restful service using junit. The restful service provides json data as output.I am new to this, although i have attained basic knowledge but still do not know what to test.Please help.
Ok. So there are several things that could / should be done.
Unit test the Controller directly. Mock all other classes.
Attempt to use any framework provided testing utilities to test how the controller interacts with the framework. An example of this is Spring's MockMVC. For an example, check out the "correct" answer to this question: JUnit test for ExceptionHandler
Both of the above to not require a deployed service to test and so work well in the test phase of maven.
Additionally, although this would be an integration test, you could write JUnit tests using RestTemplate to hit the running service and verify the results. Since this has the external dependancy that the service is deployed and doesn't use any mocks it is an integration test. That said, it is a very valid set of tests and can be written in JUnit. However, these tests should be named (or categorized) as Integration tests so that they can be isolated from the tests that do not have external dependancies.
The fact that the service provides JSon should not be a big deal. Just use Jackson to unmarshal it into a domain object and verify the values are what you expect.
Send request and test the response. You may use restfuse.
I'm in the process of building a Carbon Archive using the new WSO2 Developer Studio. I'm trying to work out how I can wrap the components (Sequences/Proxies etc) in JUnit tests. These tests will need to run as part of a CI build process (Jenkins) in order to detect errors with any modified code. I've done some research and can't seem to find anything that immediately stands out on how to achieve this. I did find this link https://wso2.org/jira/browse/TOOLS-855
which suggests that it hasn't yet been implemented. Can anyone confirm when this will be implemented or if there is any way at present to achieve this?
There is currently no straight forward way to implement this scenario and this feature will be supported in a future version.
One mechanism i can think is that, add a separate Test module as a part of the build which executes after building C-Apps.
So what happens in here is that, first Jenkins produce the CAR file for C-Apps. Then Maven start executing the JUnit test suite. Before the execution of Test Suite, you can configure maven to copy the CAR files to Servers and start up server. Then execute the Test Cases against the started up server.
This way you can deploy the new CAR files in your Carbon Server and execute the tests against the new configuration in the Server.
Thanks and Regards,
Harshana