Writing unit tests in Python: How do I start? [closed]

If you’re brand new to using unittests, the simplest approach to learn is often the best. On that basis along I recommend using py.test rather than the default unittest module. Consider these two examples, which do the same thing: Example 1 (unittest): import unittest class LearningCase(unittest.TestCase): def test_starting_out(self): self.assertEqual(1, 1) def main(): unittest.main() if __name__ … Read more

What is The Turkey Test?

The Turkey problem is related to software internationalization or simply to its misbehavior in various language cultures. In various countries there are different standards, for example for writing dates (14.04.2008 in Turkey and 4/14/2008 in US), numbers (i.e. 123,45 in Poland and 123.45 in USA) and rules about character uppercasing (like in Turkey with letters … Read more

How to test code dependent on environment variables using JUnit?

The library System Lambda has a method withEnvironmentVariables for setting environment variables. import static com.github.stefanbirkner.systemlambda.SystemLambda.*; public void EnvironmentVariablesTest { @Test public void setEnvironmentVariable() { String value = withEnvironmentVariable(“name”, “value”) .execute(() -> System.getenv(“name”)); assertEquals(“value”, value); } } For Java 5 to 7 the library System Rules has a JUnit rule called EnvironmentVariables. import org.junit.contrib.java.lang.system.EnvironmentVariables; public class … Read more

Can I run multiple versions of Google Chrome on the same machine? (Mac or Windows)

In the comments, I mentioned a step-by-step method to easily install multiple Chrome versions, side-by-side. This answer quotes my original answer, and includes a script which does the job for you. Quoted from: section 7 of Cross-browser testing: All major browsers on ONE machine: Chrome: Stand-alone installers can be downloaded from File Hippo. It is … Read more

Fetching values from email in protractor test case

This is something I’ve solved recently. Hope the solution would also apply for your use-case. Prerequisites: mail-listener2 package understanding of the concept of promises Step by step instructions: Install mail-listener2: npm install mail-listener2 –save-dev In your protractor config initialize Mail Listener and make it available globally: onPrepare: function () { var MailListener = require(“mail-listener2”); // … Read more