dimanche 31 juillet 2016

Where can I find best tutorial for mocha - chai?

I want to learn javascript testing with mocha - chai. Please suggest best tutorial for the same.

Feedback tool for clients to give UAT

I wonder if there is a feedback tool to use for clients to give UAT? I heard one tool 'www.userback.io' and wondering if there are any other tools similar to this?

An ideal tool would be:

  • Easy to use for non technical users
  • Some kind of screenshot function
  • Able to respond to a specific issues in a ticket like fashion

Combining EasyTest/JUnitParameter alike with ObjectMother pattern

I was wondering whether I can use annotations with tools like JUnitParameter with an Object mother pattern. For example.

class EmployeeObjectMother {
    @DataProvider(filepath = "ceoEmployee.csv") 
    public static Employee getCeoEmployee(@Param String name, @Param Double salary) {
        Employee employee = new Employee(name, salary);
        return employee;
    }
}

class EmployeeTest {

   // some annotation magic
   // parameter = EmployeeDataprover.getCeoEmployee 
   void shouldBeAnEmployee(Employee employee) {
       // do some testing
   }

}

In addition if it would be nice to have list of Employees through annotation magic such as:

   // annotation magic
   // annotation parameter parameter: List of employees and run for each of the item from the 
   // list
   void shouldBeAnEmployee(Employee employee) {
   }

I am not sure this is even possible or exists. If not then what is the way we can achieve Object Mother obtain its parameters and avoid coupling it with literal file name in its code. Please enlighten me.

Thanks

Dos and don'ts of testing a multi-step process

I have code which rewrites a context-free grammar into Chomsky Normal Form. I wish to test this, in particular with property testing. The code under test looks something like this:

chomsky_normal_form(cfg) do:
    intermediate_value_1 = step1(cfg)
    intermediate_value_2 = step2(intermediate_value_1)
    ...
    output step5(intermediate_value_4)

For each step there is a postcondition which should hold. There is also an invariant which should hold both before the first step and after each step. There is also a transition invariant which should hold for (cfg, iv1), for (iv1, iv2) etc. up to the last pair.

One approach to testing this is to write a method which asserts all of the postconditions and invariants.

One downside to this that I can spot is that I have to print out the failing values and the context of the test, instead of having the testing framework do some of that work for me.

It also appears to go against the spirit of property testing, but I can point to how exactly that would cause something undesirable to happen. Can you?

Another approach is to split this up into one test case (property) per aspect I want to test.

A downside is that there will be O(s^2) properties where s is the number of phases: one testing postcondition i after phase k for k=1..n and i=1..k. On top of this, n properties testing the transition invariants and n+1 testing the input-and-step invariant.

I can probably do this with code of length O(s), and without any duplication, but it seems very excessive even so.

To the extent I want to run many and/or large inputs through this gauntlet I would have to care about performance, and this looks like a lot of duplicated computations.

The question: what have you learned (from experience or otherwise) about the utility of either test approach? Is there some third approach I'm not seeing? Or is the answer just to suck it up and apply the elbow grease to test each step separately?

I think the best might be to have a framework which supports the first approach, in which I could accumulate a list of errors during the run, have the test fail if the list is non-empty, and have the framework present the list of errors in sensible ways; for property testing, it should also show contrasting pairs for the (non-)occurrence of each observed error. Does something like this exist? Am I right in wanting this, or would this be a bad idea for some reason I'm not seeing?

Practicalities: I'm writing this in Rust. Tool suggestions are welcome.

Irrelevant concrete details: the universal invariant I want to enforce is the welformedness of the representation of the context-free grammar (i.e. no dangling pointers). The post-conditions are that each step has done what it says on the tin, e.g. after the step which splits large right-hand-sides into smaller ones, all the right-hand sides are small. The step-transition invariant is that the language is preserved (which is undecidable, so I'll test strict preservation on finite languages and preservation of some sensitive features on more general language classes.)

Jasmine wait till function called by listener gets executed

So I have this function which is called when some backbone model attribute is set. I.e:

this.listenTo(model, "change:someattr", changeCallback);

What I want to do in my Jasmine tests is to set this attribute and then check if changeCallback got called successfully and if it resulted in desired changes. In my code below it looks like my changeCallback function gets called after jasmine assertions are executed.

that.model.set('someattr', 'xyz');
expect(that.model.changeCallback).toHaveBeenCalled();

Any ideas how to test this? All code examples I've found deal with asych calls which are executed directly on asynchronous function.

How to check the coming output from main method?

By example, having the next main code:

public class Solution {
   public static void main(String []argv)   {
       System.out.println("Hello World.");
       System.out.println("Hello Java.");
   }
}

I whan to know how code plataform(By example: Hackerrank) check that main method is printing the expected output.

Hello World.
Hello Java.

Is not easy imagine how to do it with Junit, at first sight. I believe that an external program is checking the output, I mean something like this:

$ java Solution | runtests

From already thank you very much.

What kind of test scenarios should be run in case of Integration API testing

In theory, when we need to start the integration API testing, which test scenarios should be run during Integration API testing? Could someone give me a list about the ideas? Interview question can be the following: What test cases should be implemented during the API testing? (high level) Any tutorial, books and articles would be appreciated as well!

E.g: Testing, the response code in a particular situation (200,400,404,500 etc.); session token test etc. what more?

Tests are failing if run through TestNG xml, but works if run it independently

I have got two tests which i am attempting run through testNG xml. If i run those independently, it works. But 1 st test is failing if i run it as a suit with xml. I have 2 classes for 2 pages - HomePage & LoginPage which has web elements and its method 1 TestBase class which invokes the browser 2 tests - VerifyHomePage - in which i am validating the tile of the page VerifyLoginPage - Validating the login functionality.

HomePage Class -

package com.Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
public class HomePage 
    {
    WebDriver driver;
     @FindBy(how = How.LINK_TEXT, using = ("Log In"))
     WebElement loginlink;
     public HomePage(WebDriver driver)
    {
        this.driver = driver;
    }
    public  void clicklogin()
    {
        loginlink.click();
    }
}


LoginPage Class -

package com.Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class LoginPage {
    WebDriver driver;
    @FindBy(how = How.XPATH, using= (".//*[@id='fk-mainbody-id']/div/div/div[1]/div/div[4]/div[2]/input"))
    WebElement email;
    @FindBy(how = How.XPATH, using= (".//*[@id='fk-mainbody-id']/div/div/div[1]/div/div[4]/div[4]/input"))
    WebElement pwd;
    @FindBy(how = How.XPATH, using= (".//*[@id='fk-mainbody-id']/div/div/div[1]/div/div[4]/div[7]/input"))
    WebElement loginbtn;
    @FindBy(how = How.LINK_TEXT, using= ("My Account"))
    WebElement myAccount;
    public LoginPage (WebDriver driver)
    {
        this.driver = driver;
    }
    public void enteremail(String Userid)
    {

              email.sendKeys(Userid);
    }
    public  void enterpwd(String passwd)
    {
        pwd.sendKeys(passwd);
    }

    public void clickLoginButton()
    {
    loginbtn.click();   
    }
    public boolean checkMyAccount()
    {  
        WebDriverWait wait = new WebDriverWait(driver,30);
        wait.until(ExpectedConditions.visibilityOf(myAccount));
        return myAccount.isDisplayed();
    }
}


TestBase Class -

package com.TestCases;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
public class TestBase {
    WebDriver driver ;
@BeforeTest
public  void invokeBrowser()
{
    //System.setProperty("webdriver.chrome.driver", "/Users/shreshthathakre/Documents/JAR Files/chromedriver");
    driver = new FirefoxDriver();
    //driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.get("http://ift.tt/NDSSYa");
    driver.manage().window().maximize();    
}
@AfterTest
public  void teardown()
{
    driver.quit();
}
}


VerifyHomePage Test -

package com.TestCases;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.Pages.HomePage;
public class VerifyHomePage extends TestBase 
{
    @Test
    public void VerifyHomePageTitle() throws InterruptedException 
    {
        HomePage hpage = PageFactory.initElements(driver,HomePage.class);
        System.out.println("Test Pass");
        Assert.assertEquals(driver.getTitle(), "Online Shopping India | Buy Mobiles, Electronics, Appliances, Clothing and More Online at Flipkart.com");
        hpage.clicklogin();
    }
}


VerifyLogin Test -

package com.TestCases;
import org.testng.annotations.Test;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import com.Pages.HomePage;
import com.Pages.LoginPage;
public class VerifyLogin extends TestBase
{
@Test
    public void checkLoginfunction() throws InterruptedException
    {
    HomePage hpage = PageFactory.initElements(driver,HomePage.class);
    hpage.clicklogin();
    LoginPage loginp = PageFactory.initElements(driver,LoginPage.class);
    loginp.enteremail("shreshtha.thakre@gmail.com");
    loginp.enterpwd("Shreshtha!1");
    loginp.clickLoginButton();
    loginp.checkMyAccount();
    Assert.assertTrue(loginp.checkMyAccount());
    }
}

Example test of go templates fails with imported and not used: "testing"

As far as I can tell I'm following structure needed for 'go test' flawlessly. I don't see a discrepancy from tests I could run in other packages. 'go build' works fine. I'm getting

./HelloTemplate_test.go:3: imported and not used: "testing" ./HelloTemplate_test.go:5: undefined: Testing in Testing.T

What am I missing?

HelloTemplate.go

package templateprint

import "testing"

func TestRunTempl(t *Testing.T) {
    sweaters := Inventory{"wool", 17}
    tmpl := " items are made of "
    err := RunTempl(tmpl, sweaters)
    if err != nil {
        t.Error("Template failed ")
    }
}

HelloTemplate_test.go

package templateprint

import (
    "os"
    "text/template"
)

type Inventory struct {
    Material string
    Count    uint
}

func RunTempl(templ string, inv Inventory) error {
    tmpl, err := template.New("test").Parse(templ)
    if err != nil {
        return (err)
    }
    err = tmpl.Execute(os.Stdout, inv)
    if err != nil {
        return (err)
    }
    return nil
}

samedi 30 juillet 2016

Ruby: test returns ArgumentError

Greeting Stackoverflow fellow people! I'm learning Ruby and as one of the intro exercises I'm meant to type "test" and receive "nil"

However I receive this instead:

ArgumentError: wrong number of arguments (0 for 2..3)
    from (irb):15:in `test'
    from (irb):15
    from /usr/bin/irb:12:in `<main>'

Does anyone know if I need to fix something, because I can't seem to find anything on this anywhere I've looked so far.

Thanks in advance!

How to extract value from regular extractor/beanshell post processor in jmeter

"\t\t

  • Employee
  • Frequency
  • Total hours
  • Stage
  • Action
  • First Name * Last Name
  • 25-07-2016 To 31-07-2016
  • 3.0
  • NEW
  • |
  • FirstName1 LastName1
  • 25-07-2016 To 31-07-2016
  • 24.43
  • NEW
  • |
  • FirstName2 LastName2
  • 25-07-2016 To 31-07-2016
  • 10.0
  • NEW
  • |
  • FirstName3 LastName3
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName4 LastName4
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName5 LastName5
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName6 LastName6
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName7 LastName7
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName8 LastName8
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName9 LastName9
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName10 LastName10
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName11 LastName11
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName12 LastName12
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName13 LastName13
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName14 LastName14
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName15 LastName15
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName16 LastName16
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName17 LastName17
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName18 LastName18
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName19 LastName19
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • FirstName20 LastName20
  • 25-07-2016 To 31-07-2016
  • 0.0
  • NEW
  • |
  • \t"

This is the response code, i need to extract the values of all ids from onclick='myTimesheet(\"Id\",\"Start date\",\"End date\"); how to get this at once by using regular expression extractor or bean shell post processor

thenReturn in not working

Unittestingclass

public class CollectionImplementationUnitTest {

CollectionImplementation col_Imp;

  public void setup() throws Exception {
  ....
  col_Imp = Mockito.spy(new CollectionImplementation());
  ....
  }

  private String mockHistoryFromStrgyTable(){
        String  value1  =   "myValue";
        return  value1;
  }

 @Test 
  public void testgetinfo (){
  ......
  Mockito.when(col_Imp.HistoryFromStrgyTable(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn(   mockHistoryFromStrgyTable());
  CollectionsAccount Info = col_Imp.AccountInfo("string1","string2","string3", new IdentityAcc(), TableLst)
  //sometestmethods and asserts
  }

}

CollectionImplementation.class

    public class CollectionImplementation{
      .....
      @override
      public CollectionsAccount AccountInfo(("string1","string2","string3", new IdentityAcc(), TableLst)){
      DetailsHelper helper = new (db2, "string",getmethod());
      return helper.AccountInfo("string1","string2", new IdentityAcc(), TableLst); 
      }
     public String HistoryFromStrgyTable(){
  //contains a call to the data base
  }
    }

DetailsHelper

public class DetailsHelper{
  public CollectionsAccount AccountInfo((String string1,String string2,String string3, new IdentityAcc(), TableLst)){
  ...
  String paymentdetails = HistoryFromStrgyTable();  
  }
   public String HistoryFromStrgyTable(){
   //contains a call to the data base
   }
}

When I try to mock the data for the method HistoryFromStrgyTable() it is actually making a call to HistoryFromStrgyTable() instead of getting from mockHistoryFromStrgyTable().

My test cases are failing at this line Mockito.when(col_Imp.HistoryFromStrgyTable(Mockito.anyString(),Mockito.anyString(),Mockito.anyString())).thenReturn( mockHistoryFromStrgyTable());

Can anyone help me with this. I don't understand what's wrong. I also changed the method mockHistoryFromStrgyTable() from private to public since mockito cannot mock private methods.

How can I cancel?

I have been testing in app billing on android with a test account, but after making my first test purchase, I want to cancel it and test again. According to the documentation:

Canceling completed test purchases

Google Play accumulates completed test purchases for each user but does not pass them on to financial processing.

In some cases, you might want to manually cancel a test purchase to continue testing. To do so, open the app page in the Play Store.

Important: The refund() and revoke() methods of the Purchases.subscriptions API don't support test purchases.

The documentation says to just open the app page in the play store...but there are no options to cancel test purchases on the app page...

Also, I can't use refund() or revoke() to cancel it programmatically, so I'm stuck with trying to figure out how to do this manually. How can I cancel my test purchase?

Thanks,

Ruchir

EDIT: Note this is NOT a subscription, but a regular item purchase, which is why I cannot use the cancel() method.

After adding the gem "webmock" I have "uninitialized constant Syck (NameError)"

I've added gem "webmock" and started having an error:

$ rspec
/home/me/.gem/ruby/2.3.1/gems/safe_yaml-1.0.1/lib/safe_yaml/syck_node_monkeypatch.rb:42:in `<top (required)>': uninitialized constant Syck (NameError)

I've tried includig this:

 module SafeYAML
  YAML_ENGINE = defined?(YAML::ENGINE) ? YAML::ENGINE.yamler : (defined?(Psych) && YAML == Psych ? "psych" : "syck")
end

into different initialization files such as application.rb and initializers/my_init.rb, but it didn't help to fix the error. How can I fix it?

How to run android Instrument test on Multiple devices at a time

I want to run my test cases on 2 devices together.How can I do this via android studios or command line?

Test get crushed because of error " dangerouslyRenderMarkup " in react enzyme mocha testing

The full error text is Invariant Violation: dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure window and document are available globally before requiring React when unit testing or use ReactDOMServer.renderToString for server rendering.

I have searched this issue but all solutions are connected with jsdom set up. My jsdom set up is here :

import jsdom from 'jsdom';
import jquery from 'jquery';
import TestUtils from 'react-addons-test-utils';
import ReactDOM from 'react-dom';
import chai, { expect } from 'chai';
import React from 'react';
import chaiJquery from 'chai-jquery';

// Set up testing environment to run like a browser in the command line
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
global.window = global.document.defaultView;
global.navigator = global.window.navigator;
const $ = jquery(global.window);

// build 'renderComponent' helper that should render a given react class
function renderComponent(ComponentClass, props, state) {
   const componentInstance = TestUtils.renderIntoDocument(
      <ComponentClass {...props} />
   );

   return $(ReactDOM.findDOMNode(componentInstance)); // produces HTML
}

// Build helper for simulating events
$.fn.simulate = function(eventName, value) {
   if (value) {
      this.val(value);
   }
   TestUtils.Simulate[eventName](this[0]);
}

// Set up chai-jquery
chaiJquery(chai, chai.util, $);

export { renderComponent, expect };

p.s. i don't use renderComponent function. I use enzyme mount instead

here is example of my test code

'use strict';
import React from 'react';
import { shallow, mount } from 'enzyme';
import sinon from 'sinon';
import chai, { expect } from 'chai';
import Profile_Store from '../profile.store';
import Signup from '../components/signup.component';

describe('__Signup__', ()=> {
   let signup_stub, spySubmit, spyCloseHint, wrap, context, email, pssword, passwordConfirm, submit, form_hint, input__hint;

   beforeEach(() => {
      spySubmit = sinon.spy(Signup.prototype, 'handleSubmit');
      signup_stub = sinon.stub(Profile_Store.prototype, 'signup');
      spyCloseHint = sinon.spy(Profile_Store.prototype, 'clearErrorMessage');
      context = {
         profile: new Profile_Store()
      };
      wrap = mount(<Signup  />, {context});
      email = wrap.find('input[type="email"]');
      pssword = wrap.find('input[type="password"]');
      submit = wrap.find('button[type="submit"]');
      input__hint = wrap.find('.input__hint');
      form_hint = wrap.find('.form__hint');
   });
   afterEach(() => {
      spySubmit.restore();
      spyCloseHint.restore();
      signup_stub.restore();
   });

   it("contains all inputs, button and validation hints", function() {
      expect(email).to.have.length(1);
      expect(pssword).to.have.length(2);
      expect(submit).to.have.length(1);
      expect(form_hint).to.have.length(1);
      expect(input__hint).to.have.length(3);
   });

   it("validation messages are hidden by default", function() {
      expect(form_hint.hasClass('hidden')).to.equal(true);
      input__hint.forEach((hint) => {
         expect(hint.hasClass('hidden')).to.equal(true);
      });
   });

   it("validation messages are visible if error", function() {
      context = {profile: new Profile_Store()};
      wrap = mount(<Signup  />, {context});
      wrap.context().profile.errorMessage = 'registration failed';
      expect(wrap.find('.form__hint').hasClass('visible')).to.equal(true);
      expect(wrap.find('.form__hint > span').at(0).text()).to.equal('registration failed');
   });

   it("validation messages are hidden while click close hint", function() {
      context.profile.errorMessage = 'registration failed';
      wrap = shallow(<Signup  />, {context});
      wrap.find('.form__closeHint').simulate('click');
      expect(context.profile.errorMessage).to.equal('');
      wrap = shallow(<Signup  />, {context});
      expect(wrap.find('.form__hint').hasClass('visible')).to.equal(false);
      sinon.assert.calledOnce(spyCloseHint);
   });

   it('form work correctly', () => {
      const event = {target: {value: 'cats'}};
      wrap.ref('email').simulate('change', event);
      wrap.simulate('submit',  { preventDefault() {} });
      chai.assert.equal(spySubmit.callCount, 1);
      sinon.assert.calledOnce(signup_stub);
   });

   it('don\'t handle Submit with empty values', () => {
      wrap.setState({
         validEmail: null,
         validPassword: null,
         validPasswordConfirm: false
      });
      wrap.simulate('submit',  { preventDefault() {} });
      sinon.assert.notCalled(signup_stub);
   });
});

C, how can a macro register a unittest for execution?

How can libraries such as GTest use a single macro G_TEST(...) to both define the function and register it as a test function? I'm looking for a way to do the same for my C99 project.

Example

TEST_MACRO(mytest)
{
    printf("Hello, world\n");
    return 0;
}
TEST_MACRO(mytest2)
{
    printf("Hello, world 2\n");
    return 2;
}

void main(int argc, char** argv)
{
    RUN_TESTS();
}

Can't figure out how to register the tests so they are known from RUN_TESTS()

vendredi 29 juillet 2016

Automate app-testing (phantomjs) and merging branches

I would like to automate testing and merging / deploying my application.

Fist I do testing via Chimp and ESLint:

$ chimp --ddp=http://localhost:3000 --mocha --path=tests --browser=phantomjs

and

$ eslint ./

If these tests are passing completly, I would like to merge the development branch to the master branch:

git checkout master
git merge development

Is it possible to automate these steps? So if any test is failing, no merge should be done.

Preload scene stops responding upon transitioning Unity 3D

I have a game with four scenes, a menu scene, a loading scene, and two game scenes. All is well, when I am transitioning from my menu scene to my game scenes, but whenever I transition from my game scenes back to my menu scene or reload the game scene, the loading scene simply stops responding. I have two scripts that controls transitioning. One simple script called on UIButtons for telling the second more complex script called in the preload scene to load the scene it's supposed to load and create animations. I have made sure that I was loading on to the correct scene, and that all of the scenes were in added in to my build settings.

The following pictures show the loading scene not responding:

Loading Screen Freezing when I try to reload the game scene

Loading Screen Freezing when I try to load the menu scene

My Loading Scene Script:

public class LoadingScreenManager : MonoBehaviour {

[Header("Loading Visuals")]
public Image loadingIcon;
public Image loadingDoneIcon;
public Text loadingText;
public Image progressBar;
public Image fadeOverlay;

[Header("Timing Settings")]
public float waitOnLoadEnd = 0.25f;
public float fadeDuration = 0.25f;

[Header("Loading Settings")]
public LoadSceneMode loadSceneMode = LoadSceneMode.Single;
public ThreadPriority loadThreadPriority;

[Header("Other")]
// If loading additive, link to the cameras audio listener, to avoid multiple active audio listeners
public AudioListener audioListener;

AsyncOperation operation;
Scene currentScene;

public static int sceneToLoad = -1;
// IMPORTANT! This is the build index of your loading scene. You need to change this to match your actual scene index
static int loadingSceneIndex = 1;

public static void LoadScene(int levelNum) {                
    Application.backgroundLoadingPriority = ThreadPriority.High;
    sceneToLoad = levelNum;
    SceneManager.LoadScene(loadingSceneIndex);
}

void Start() {
    if (sceneToLoad < 0)
        return;

    fadeOverlay.gameObject.SetActive(true); // Making sure it's on so that we can crossfade Alpha
    currentScene = SceneManager.GetActiveScene();
    StartCoroutine(LoadAsync(sceneToLoad));
}

private IEnumerator LoadAsync(int levelNum) {
    ShowLoadingVisuals();

    yield return null; 

    FadeIn();
    StartOperation(levelNum);

    float lastProgress = 0f;

    // operation does not auto-activate scene, so it's stuck at 0.9
    while (DoneLoading() == false) {
        yield return null;

        if (Mathf.Approximately(operation.progress, lastProgress) == false) {
            progressBar.fillAmount = operation.progress;
            lastProgress = operation.progress;
        }
    }

    if (loadSceneMode == LoadSceneMode.Additive)
        audioListener.enabled = false;

    ShowCompletionVisuals();

    yield return new WaitForSeconds(waitOnLoadEnd);

    FadeOut();

    yield return new WaitForSeconds(fadeDuration);

    if (loadSceneMode == LoadSceneMode.Additive)
        SceneManager.UnloadScene(currentScene.name);
    else
        operation.allowSceneActivation = true;
}

private void StartOperation(int levelNum) {
    Application.backgroundLoadingPriority = loadThreadPriority;
    operation = SceneManager.LoadSceneAsync(levelNum, loadSceneMode);


    if (loadSceneMode == LoadSceneMode.Single)
        operation.allowSceneActivation = false;
}

private bool DoneLoading() {
    return (loadSceneMode == LoadSceneMode.Additive && operation.isDone) || (loadSceneMode == LoadSceneMode.Single && operation.progress >= 0.9f); 
}

void FadeIn() {
    fadeOverlay.CrossFadeAlpha(0, fadeDuration, true);
}

void FadeOut() {
    fadeOverlay.CrossFadeAlpha(1, fadeDuration, true);
}

void ShowLoadingVisuals() {
    loadingIcon.gameObject.SetActive(true);
    loadingDoneIcon.gameObject.SetActive(false);

    progressBar.fillAmount = 0f;
    loadingText.text = "LOADING...";
}

void ShowCompletionVisuals() {
    loadingIcon.gameObject.SetActive(false);
    loadingDoneIcon.gameObject.SetActive(true);

    progressBar.fillAmount = 1f;
    loadingText.text = "LOADING DONE";
}

}

Script on UIButtons that call the above script: public class LoadingSceneButton : MonoBehaviour {

public void LoadSceneWithLoadingScreen(int sceneNumber){
    if (sceneNumber < 0 || sceneNumber >= SceneManager.sceneCountInBuildSettings) {
        Debug.LogWarning ("Can't Load Scene, because It Doesn't Exist!");
    }

    LoadingScreenManager.LoadScene (sceneNumber);
}
}

Improving code coverage for the @builder in Lombok

Is there a way to test the @Builder annotation used in Lombok? I use the pattern to build my classes and my code coverage keeps dropping as I use it more.

Any ideas on this?

LTspice unable to add a new part

I am attempting to add a part to a standard file (in ~\lib\cmp) by copying the contents of a new model (found here) and pasting it at the end of the existing standard file. However, after I add a part to my schematic, when I click to pick a new part I am asked to choose a new file from that same part type. When I do, it does not allow me to select it. The dialogue box remains open and is stuck on this page.

Any suggestions - am I adding a part incorrectly? Thanks.

Confusion with mocking stateless React component helper functions with sinon, enyzme, and ES6 imports

I'm currently trying to unit test a React component and have run into some confusion about mocking functions the helper functions. The module looks something like this

export const someHelper = () => {
  return ( <div></div> )
}

const MyComponent = () => {
  return (
    <span>
      {someHelper()}
    </span>
  )
}
export default MyComponent

and then this is what the test file looks like

import chai, { expect } from 'chai'
import chaiEnzyme from 'chai-enzyme'
import sinon from 'sinon'
import { shallow } from 'enzyme'
import React from 'react'

import MyComponent, { someHelper } from './MyComponent'

describe('MyComponent test', function (){
  it.only('should call someHelper once', function () {
    let spy = sinon.spy(someHelper)
    let myComponent = shallow(
      <MyComponent />
    )
    expect(spy.callCount).to.equal(1)
  })
})

This test fails however as callCount equals 0. I figured that maybe it had something to do with the context of the someHelper function, so I made these changes

export const helpers = {
  someHelper () {
    ...
  }
}
const MyComponent = () => {
   ...
   {helpers.someHelper()}
   ...
}

_

import MyComponent, { helpers } ...

describe(...{
  it(...{
    let spy = sinon.spy(helpers.someHelper)
     ...
  })
})

But this test still fails with callCount equaling 0. I then made these changes

describe(...{
  it(...{
    let spy = sinon.spy(helpers, 'someHelper')
     ...
  })
})

And then test now passes.

Why do I have to attach someHelper to the helpers object for this test to work? And why do I have to use that last spy(object, 'myfunc') method when the sinon docs show a spy(myFunc) option?

Testing request and response messages format with IBM MQ

I have over 1000 sample messages.Simply, I send this message to MQ and receive the response, one by one.These response should be validated against to the request messages.What would be the most effective way I can do the testing using JBehave , Junit and java?. (One message represents a particular scenario).

Why is the first Rspec View test ran always the slowest?

Below is my Rspec output and as you can see the first test to run is always the slowest. The first time it was line 18, the second time it was line 27. Could the test be doing any sort of caching?

❯ spec spec/views/principals/show.html.haml_spec.rb -p                                                            mbc
Run options:
  include {:focus=>true}
  exclude {:ignore=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 25466
..

Top 2 slowest examples (3.47 seconds, 94.4% of total time):
  /principals/show the MINDEX tab a permitted user has tab and a link to the tab
    3.41 seconds ./spec/views/principals/show.html.haml_spec.rb:18
  /principals/show the MINDEX tab a not-permitted user does not have tab or a link to the tab
    0.05673 seconds ./spec/views/principals/show.html.haml_spec.rb:27

Finished in 3.68 seconds (files took 5.98 seconds to load)
2 examples, 0 failures

Randomized with seed 25466

❯ rspec spec/views/principals/show.html.haml_spec.rb -p                                                            mbc
Run options:
  include {:focus=>true}
  exclude {:ignore=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 33681
..

Top 2 slowest examples (3.98 seconds, 94.9% of total time):
  /principals/show the MINDEX tab a not-permitted user does not have tab or a link to the tab
    3.73 seconds ./spec/views/principals/show.html.haml_spec.rb:27
  /principals/show the MINDEX tab a permitted user has tab and a link to the tab
    0.25015 seconds ./spec/views/principals/show.html.haml_spec.rb:18

Finished in 4.2 seconds (files took 6.91 seconds to load)
2 examples, 0 failures

Randomized with seed 33681

And here are my tests....

RSpec.describe "/principals/show" do

  before do
    @principal = FactoryGirl.build_stubbed(:principal)
    FactoryGirl.build_stubbed(:financial_statement, principal: @principal)
    @financial_statements = @principal.financial_statements.paginate(per_page: 5, page: 1)
    @merchants_index = MerchantsIndex.new(@principal)
    allow(@view).to receive(:current_user).and_return(mock_model(User).as_null_object)
    allow(@view).to receive(:permitted_to?).and_return(true)
  end

  #it "works" do
  #  expect { render }.not_to raise_error
  #end

  describe "the MINDEX tab" do
    context "a permitted user" do
      it "has tab and a link to the tab" do
        expect(@view).to receive(:permitted_to?).with(:read, :merchants_index).twice.and_return(true)
        render
        expect(rendered).to have_selector("a[href='#mindex']")
        expect(rendered).to have_selector("div#mindex")
      end
    end

    context "a not-permitted user" do
      it "does not have tab or a link to the tab" do
        expect(@view).to receive(:permitted_to?).with(:read, :merchants_index).twice.and_return(false)
        render
        expect(rendered).not_to have_selector("a[href='#mindex']")
        expect(rendered).not_to have_selector("div#mindex")
      end
    end
  end

end

ArrayList

This test give me all status in Boolean value True or False from API.

List<Boolean> allStatus = event.getResponse().getBody().jsonPath().getList("enabled");

There is no specific idea how many status will be or there is no fix size.It can be 20 or 1.

To check this assertion, I was writing for loop and check each value.

assertNotNull(allStatus);
for (Boolean status : allStatus) {
    assertEquals("FAILED Disable event status ", false, status);
}

I am trying to know what is better way to handle such scenario ?

Are there any interesting PhantomJS alternatives that support html5 video or flash?

All right. So we have this software platform in our company that we use to test our clients websites. It consists of around 30 VPS servers (controlled from a single machine) which spawn Phantoms, each VPS can run around 150 of these simultaneously. That setup can generate quite an amount of traffic, so everything is dandy, but there's one major issue. More and more often we get asked to also do video testing, and that is not supported by PhantomJS. We tried some other solutions, like headless browsers (firefox, chrome), but it is not as resource effective as PhantomJS. It comes down to that a single VPS can only run about 10 headless browsers before it runs out of CPU/MEM. This means that we would have to scale the platform 10-15 times bigger, which is beyond our budget.

Because our whole platform is quite old (almost two years now), and no one has ever tried to improve it, i thought i would ask some of the more up-to-date developers, can you suggest any alternatives to PhantomJS that would be similar in resource consumption but could also support video, and of course, scripting? Does anything like that exist? This advice would be greatly appreciated. Thanks a lot.

What is the most idiomatic way in Go to test code which has dependency on structure with big amount of methods?

Lets say I have a UserRepository struct which incapsulates logic for interacting with a database. This struct has a set of methods like:

  • findAll()
  • findById()
  • findByName()
  • save()
  • and so on....

There is another struct (let's call it UserService for instance) which depends on UserRepository struct.

To test UserService I need to mock functionality of UserRepository. The only way I know to do this is to provide the interface for UserRepository and make UserService be dependent on it instead of UserRepository struct. It will allow to create a mocked implementation of interface and set it as dependency of UserService in the test.

What is the most idiomatic way to do it?

1) If UserService depends only on 1 UserRepository's method (let's say findAll) - should I still define an interface which will have all repository methods or it's better to define a separate interface for this method only and use it as a dependency of UserService? If so, what is the best name for it (interface)? If another struct will depend on findAll() and findById() methods should I again create another interface?

2) Where is a best place to store mocks for these interfaces? Is it possible to reuse them? Or for tests of different structs I will need redefine the mocks?

P.S. as for me unit tests is a very important part of the project. I would like to make them as readable as possible avoiding boilerplate code and focusing on their logic. So creating several mock implementations for same interfaces in different test files looks for me a bad option since it makes test code less readable.

Cross browser testing service

I can not finde any service to make cross browser test, I just finde tools?

Can any one recommend a service for cross-browser on all device for the testing?

Testing against early returns (defensive programming)

I am learning testing and trying to test a function using 'early returns'. The function on success sets a property in another class and on failure simply returns so in both cases it 'returns' void.

class Test
{
    private $fileHandler;
    private $config;

    public __constructor($fileHandler, $config)
    {
        $this->fileHandler = $fileHandler;
        $this->config = $config;
    }

    public function example($filePath)
    {
        $exists = $this->fileHandler->exists($filePath);

        if ($exists === false) {
             return;
        }

        $this->config->set($filePath);
    }
}

In this example I believe I can test this with two unit tests and by mocking the fileHandler class.

For a failure (early return) the $config class's method set() should not be called whilst for a success the method should be called.

However, this test passes if I try and change never() to once() making me think the entire test is bogus.

/** test */
public function config_is_not_set_with_missing_file()
{
    $fileHandlerMock = $this->getMockBuilder(fileHandler::class)->getMock;
    $fileHandlerMock->method('exists')
        ->willReturn('false');
    $configMock = $this->getMockBuilder(config::class)->getMock;

    $test = new Test($fileHandlerMock);
    $test->example('fake file path');

    $configMock->expects($this->never())
        ->method('set');
}

Effective and current way to test Asp.Net MVC applications on Android and ios

I appreciate there is a lot of information around this that you can access via a quick internet search. However, I feel there is so much that is difficult to find the most up to date and accurate information.

We are working in a Windows environment running Asp.Net MVC applications with JavaScript. So, my question is very specific to that scenario.

I need up to date help with recommending an approach and tools for debugging\recreating issues found on apple or android devices.

  • Is it necessary\best to have an apple machine to connect apple device to?

  • Is it necessary\best to have an android device connected to a Windows PC?

  • Are there any tools\emulators that can do either or both on a Windows environment?

Any other advice would be appreciated.

Software test description

I am making STD for my project and I came across with test plan identifiers, test design specification identifiers, test case specification identifiers, test procedure specification identifier,and test summary report identifier. But I don't know what to write. Please help me thanks.

jeudi 28 juillet 2016

You need to sign in to your google account?

TL;DR: I am getting a common error with in app billing, even though I have the correct test accounts. Do I have to opt-in with my test account?

This is my first time with in app billing, and I am getting the following infamous error:

enter image description here

I have read all the documentation a couple of times, and I have added my test accounts in Google Play Console:

enter image description here

On my LG-G3 android device, I have added my test email in the accounts section (so now my phone has two google accounts associated with it)

THE PROBLEM: In the documentation, it says:

Important: To test in-app products or make in-app purchases in your alpha or beta channel app, each tester needs to opt-in to your app’s alpha or beta test. On your test’s opt-in URL, your testers will get an explanation of what it means to be a tester and a link to opt-in.

I believe the reason for my error is because I didn't opt-in with my test account. How do I get that link to opt-in? In the console it says this:

enter image description here

"An opt-in link will be available here when you publish your app." This is odd, because I thought we can test in app billing without publishing to the play store? How can I fix this and get the opt in link?

Thanks,

Ruchir

Junit test class in android studio

I'm trying to create a LOCAL JUNIT Test class for my database-class in Android. However I'm running into a couple of problems. This is an example of the test-class I want to create:

import android.test.AndroidTestCase;
import android.test.RenamingDelegatingContext;
import com.example.c.readit.model.Book;
import com.example.c.readit.model.VolumeInfo;
import com.example.c.readit.sqlite.SqliteHelper;
import org.junit.Test;

public class TestDB extends AndroidTestCase{
    private SqliteHelper db;
@Override
public void setUp() throws Exception {
    super.setUp();
    RenamingDelegatingContext context = new RenamingDelegatingContext(getContext(), "test_");
    db = new SqliteHelper(context);
}

@Override
public void tearDown() throws Exception {
    db.close();
    super.tearDown();
}

@Test
public void testSaveBook(){

    String test_ID = "1234";
    String test_TITLE = "TestBook";
    String test_DESCRIPTION = "TestDescription";
    String test_PUBLISHER = "TestPublisher";
    String test_READ = "yes";

    VolumeInfo testVolumeInfo = new VolumeInfo(test_TITLE,test_PUBLISHER,test_DESCRIPTION);
    Book testBook = new Book(test_ID,testVolumeInfo,test_READ);

    long wasSuccesful = db.saveBookMyBooks(testBook);

    assertTrue(wasSuccesful != -1);
}

}

However, a couple of the methods are deprecated (since API 24). When looking them up in the Android documentation I can see that we're supposed to use the 'Testing Support Library' (http://ift.tt/2a3ba50).

I am having a hard time finding examples to learn how to work with this. When I find a working example, I'm running into the problem that I cannot get the context for my SqlLite DB.How can I get the context Some examples are available for the instrumented test classes, but I want to write a local JUNIT test-class.

My gradle build:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.c.readit"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        // To fix 'Error:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (24.0.0) and test app (23.0.1) differ. See http://ift.tt/1ZPcybz for details.'
        resolutionStrategy.force 'com.android.support:support-annotations:23.0.1'
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    androidTestCompile 'com.android.support.test:runner:0.4'
    // Set this dependency to use JUnit 4 rules
    androidTestCompile 'com.android.support.test:rules:0.4'
}

Thanks

Dynamically testing authentication RESTful API (NodeJS, Mocha, SuperAgent)

Goal:

I am trying to test my authentication RESTful API. The tools i am using are NodeJS with the modules: Mocha, Supertest(.agent) and chai(.assert).

What i tried:

var users = [ new User("admin", "secretPass"), new User("guest", "Pass")];
describe('request some protected data', function(){
    users.forEach(function(user){
        before(function(){
            agent.post('/login').send({ user.username, user.key })
                .end(function(err, res) {

                }
        }

        it('get data', function(done){
            agent.get('/data').send({ user.username, user.key })
                .end(function(err, res) {
                    // assertions on data
                }
        }
    }
}

The problem:

Using something similar to the snippet above results in multiple before functions being executed at once and after that all the tests(it). So agent will always be logged in as the last user in users.

I tried to replace before with beforeEach and place it above users.forEach, but then user will be out of scope.

Can anyone provide me with a small snippet of code that will explain a suitable solution for my problem?

Change value modulo.valor () on the Protractor

I have a system using AngularJS and I'm using Protractor to test, however, would like to change a value set in module.value().

The module is thus:

'use strict';

var app = angular.module('myModule');

app.value('config',{
logo: 'images/logo.png',
apiUrl: 'http://localhost:8080/v1/', ...

In tests I tried it (not this going right):

beforeEach(function() {

    var mockedModule=function(){
        var module = angular.module('myModule').value('config',{
                apiUrl: 'http://localhost:8080/v1/'
        });
    };

    browser.addMockModule('myModule',mockedModule); 

});

I want to know how can I change the value in "apiUrl" in the tests?

Localizing fault with the help of log file

If there is a problem in the source code, usually a programmer goes through the log manually and tries to identify the problem in the source code.

But is it possible to automate this process? Can we automate the process that would give the potential lines in the source code that was responsible for generating the fault.

So, for example:

If there is some problem in the log file. Then this automation tool should say that this problem has occurred due to line 30,31,32,35,38 in source code ABC

Thanks!!

mock.calls is undefined in jest test

I’m trying to test a React component by verifying that changeWindow gets called when I click a button. However, when I run the test, changeWindow.mock.calls is undefined. I can’t figure out what I’m missing—changeWindow is defined in the test as a function and changeWindow.mock is defined as [Object object]. Any ideas?

jest.mock('../../../../../../lib/util/changeWindow');
const changeWindow = require('../../../../../../lib/util/changeWindow').default;

describe('CardPage', () => {

    it('calls changeWindowLocation() on clicking button', () => {
        const onChangeMock = jest.fn();
        const component = enzyme.shallow(<CardPage status={'welcome'} onChange={onChangeMock}/>);
        component.find(Button).at(2).simulate('click');
        expect(changeWindow.mock.calls[0][0]).toEqual('/items/');
    });
});

GOlang - Check if JSON has multiple of the same key

I'm trying to see if a .json file has multiple of the same keys

"gauge1":{
    "name":"someName",
    "name":"someName1"
}

is there a way in go to check if the key 'name' in the json is used more than once? In go if you unmarshal the json file with multiple keys of the same name, it will rewrite the previously written key and gauge1.name will become someName1

Any help would be grateful thank you!

How to run tests OL3 (Windows)?

Can not run tests via npm test:

    PS C:\inetpub\wwwroot\ol3> npm test

    > openlayers@3.17.1 pretest C:\inetpub\wwwroot\ol3
    > eslint tasks test test_rendering src examples


    > openlayers@3.17.1 test C:\inetpub\wwwroot\ol3
    > node tasks/test.js

    mocha.run() was called with no tests
    npm ERR! Test failed.  See above for more details.

Ok, Building on Windows:

  1. install Cygwin (make + nano)

  2. edit Cygwin's /etc/fstab file to disable ACLs like this none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

  3. run make

    PS C:\inetpub\wwwroot\ol3> make test
    Не найден файл: *.glsl
    Не найден файл: *.js
    Не найден файл: *.js
    Не найден файл: *.js
    FIND: Неправильный формат параметра
    Не найден файл: *.html
    Не найден файл: *.js
    FIND: Неправильный формат параметра
    npm install
    \
    > openlayers@3.17.1 install C:\inetpub\wwwroot\ol3
    > node tasks/install.js


    > openlayers@3.17.1 postinstall C:\inetpub\wwwroot\ol3
    > closure-util update

    coveralls@2.11.12 node_modules\coveralls
    ├── lcov-parse@0.0.6
    ├── log-driver@1.2.4
    ├── minimist@1.2.0
    ├── js-yaml@3.0.1 (esprima@1.0.4, argparse@0.1.16)
    └── request@2.74.0 (aws-sign2@0.6.0, forever-agent@0.6.1, tunnel-agent@0.4.3, oauth-sign@0.8.2, is-typedarray@1.0.0, cas
    eless@0.11.0, stringstream@0.0.5, aws4@1.4.1, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.3.
    1, qs@6.2.1, node-uuid@1.4.7, combined-stream@1.0.5, mime-types@2.1.11, form-data@1.0.0-rc4, hawk@3.1.3, bl@1.1.2, http-
    signature@1.1.1, har-validator@2.0.6)
    node tasks/test.js
    mocha.run() was called with no tests
    make: *** [Makefile:136: test] Error 1

Не найден файл = File not found
Неправильный формат параметра = Invalid parameter format

Oh, verify...

    C:\inetpub\wwwroot\ol3>make check
    Не найден файл: *.glsl
    Не найден файл: *.js
    Не найден файл: *.js
    Не найден файл: *.js
    FIND: Неправильный формат параметра
    Не найден файл: *.html
    Не найден файл: *.js
    FIND: Неправильный формат параметра
    Running eslint...
    node tasks/build.js config/ol.json build/ol.js
    info ol Parsing dependencies
    info ol Compiling 273 sources
    ERR! compile Java HotSpot(TM) Client VM warning: TieredCompilation is disabled in this release.
    ERR! compile
    uncompressed: 483434 bytes
      compressed: 140119 bytes
    node tasks/test.js
    mocha.run() was called with no tests
    make: *** [Makefile:136: test] Error 1

Again failure!

How to run tests OL3 ?

Testing socket.io with Zombie.js across two browsers

I'm building a real time chat app using node and socket.io. Having problems trying to feature test using Zombie. The app itself is working fine in browser but test is failing with the message

AssertionError: expected '' to include 'Hello'

During debugging it seems that when Zombie presses the send button it does not fire the 'chat message' event - though it does in development.

describe('chat feature', function() {

  beforeEach(function(done) {
    browser1 = new Browser({
      site: "http://localhost:3000"
    });
    browser2 = new Browser({
      site: "http://localhost:3000"
    });
    done();
  });

  beforeEach(function(done) {
    browser1.visit('/', done);
  });

  beforeEach(function(done) {
    browser2.visit('/', done);
  });

  describe("Chat page has been rendered", function() {
    beforeEach(function(done) {
      browser2.pressButton('Javascript testing');
      browser2.fill('.chatbox-input', 'Hello');
      browser2.pressButton('Send', done);
    });
    it('sends chat messages between browsers', function(done) {
      expect(browser1.text('li')).to.contain('Hello');
      done();
    });
  });
});

And the HTML (dynamically loading scripts into content div using jquery)

<html>

<head>
  <title>Global Code Network</title>
  <link rel='stylesheet' href='/stylesheets/style.css' />
</head>

<body>

  <div class="main">
    <h1>Global Code Network</h1>
    <div id="content"></div>
  </div>

  <div class="bottom-bar">
    <h2>Current requests:</h2>
    <div id="join-rooms"></div>
  </div>

  <script id="chat-template" type="text/template">
    <ul id="messages"></ul>
    <form id="chatbox" action="">
      <input type="text" class="chatbox-input" id="m" name="chat-input" autocomplete="off" />
      <input type="submit" value="Send"></input>
    </form>
  </script>
  <script id="end-chat-template" type="text/template"></script>
  <script src="/http://ift.tt/1aeIZU4"></script>
  <script src="http://ift.tt/1pTZRh4"></script>
  <script src="/scripts/main.js"></script>
</body>
</html>

Client side JS

(function(exports) {

  var socket = io();
  
  socket.on('person joined', function(data) {
    $('.bottom-bar').remove();
    $('#content').html($('#chat-template').html());
    $('#chatbox').submit(function(e) {
      e.preventDefault();
      socket.emit('chat message', {
        roomID: data.roomID,
        message: $('#m').val()
      });
      $('#m').val('');
    });
    socket.on('chat message', function(data) {
      $('#messages').append($('<li>').text(data.message));
    });
  });

  exports.socket = socket;

})(this);

And server side JS

io.on('connection', function(socket) {
  socket.on('join room', function(data) {
    socket.join(data.roomID);
    io.to(data.roomID).emit('person joined', {
      roomID: data.roomID
    });

    socket.broadcast.emit('update available rooms', {
      rooms: rooms
    });
  });

  socket.on('chat message', function(data) {
    io.to(data.roomID).emit('chat message', data);
  });
});

Thanks

Google Test Framework: is better to use shadowing or virtual methods?

In the example below, I want to unit test class A in order to verify that when A::request is called, B::response() is called as well:

class A
{
public:
    void request()
    {
        m_b.response();
    }

private:
    B m_b;
};

class B
{ 
public:
    void response();
};

In order to do that, class B has to be mocked:

class MockB : public B
{
public:
    MOCK_METHOD0( response, void());
};

So that the test will contain:

class TestA : public A
{
    ...
};

...
EXPECT_CALL( m_b, response( ) ).Times( 1 );
request( );
...

The question is: how to "inject" MockB as a replacement of B m_b?

First tecnique: Create a ShadowB class that redirects the method call to class MockB. This requires the original code to be in an external binary, but does not require any change in the actual code.

Second tecnique:

  • Making B::response virtual
  • Changing B m_b to a std::unique_ptr<B> m_b
  • Replace m_b value with an instance of class MockB during the test setup

Second approach means more code change and I'm not sure about its pro.

Test a method by changing final static variables

I have a protected Method which looks as follows.It uses final static variables from a Constants.java file.

class A {
    protected Configuration connectConfig() {
           ConfigDescriptor desc = new ConfigDescriptor.Builder().project(Constants.REMOTE_CONFIG_PROJECT_NAME)
            .name(Constants.REMOTE_CONFIG_PROJECT_CONFIG_NAME).version(Constants.REMOTE_CONFIG_PROJECT_VERSION)
            .build();

    return ConfigProvider.of(desc, getClass().getClassLoader());
    }

  public boolean process() {
      Configuration config = connectConfig();
      if(config == null) {
          return false;
      }
  }
}

Now I want to unit test this method process for the remote config to fail.

If I just test process() method it will pass since the Constants.java has proper values to connect. For testing I want to change these values so that remote config returns null;

Note : We don't want to use Mockito to mock the values.

How to make crypto.randomBytes cause error

crypto.randomBytes(48, function (err, buffer) {
            if (err) {
              x = false;
              return;
            }

I need to create a test code where err is true. How to let crypto.randomByte cause an error.

Test Automation framework for remote clients

I need a test automation framework for client testing. I would like to set up a host (server), and run tests against multiple clients. (These clients are mainly Windows machines with different type of OS, like Windows XP, Windows 7 etc.).

I would like to perform following tasks (I have full access to clients)

  • Open/Run some programs
  • Download files
  • Run/Install downloaded files
  • Click some UI elements on Windows Task Bar
  • and more :)

There won't be assertion on clients, I will keep track of records on different server (which client reports to there).

So I basically need a tool to perform these tasks on clients from centralized server.

I did some google search, and I only find Web App testing tools. Any suggestions are welcome!

OHHTTPStubs not stubbing network call

I am fairly new to unit testing network calls and I am going down the OHHTTPStubs route, Although I am not entirely sure how to set it up. Below is my code but the call is not returning the error I am trying to stub.

let expectation = expectationWithDescription("AddRoomErrorTest")

    stub(isHost("https://api.com")) { (_) -> OHHTTPStubsResponse in
        return OHHTTPStubsResponse(error: NSError(domain:NSURLErrorDomain, code:Int(CFNetworkErrors.CFURLErrorNotConnectedToInternet.rawValue), userInfo:nil))
    }

    let path = "/.../.../"
    let dictionary: NSDictionary = ["body": ""]

    CommonNewservice.sharedInstance.post(path, requestObject: dictionary as? Dictionary<String, AnyObject>) { (successObject: AnyObject!, errorObject: AnyObject!) in

        XCTAssertNotNil(errorObject)

        expectation.fulfill()

    }

    waitForExpectationsWithTimeout(5) { error in
        XCTAssertNil(error, "\(error)")
    }

It should return a error but error is being returned nil :S

Thanks for any help in advance

Json Schema Validation Not Fail

I am working on Json Schema Valdation with Rest Assured api. I am getting a Json response from web service and validate with this a a schema. When I change a property in schema and run the test code, test not fail. But I wanna test that any property exist there. If one of the properties that in the schema is not exist in response test must be fail. But I couldn't do this. How can I do this? My Test Code:

@Test
public void catalogButiqueDetailTest(){
    File file = new File("src/test/resources/generatedJson/boutiqueDetailSchema.json");
    JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.newBuilder().setValidationConfiguration(ValidationConfiguration.newBuilder().setDefaultVersion(SchemaVersion.DRAFTV4).freeze()).freeze();


    given()
    .headers("some-header-info")
    .contentType("application/json")
    .get("web-service-url")
    .then()
    .assertThat()
    .body(JsonSchemaValidator.matchesJsonSchema(file).using(jsonSchemaFactory));
}

org.openqa.selenium.WebDriverException: [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"

@Test public void Workflowstatus() throws Exception {

    guitils.loginToPortal(userName1, password1, driver);
    guitils.LightiningView(driver);
    driver.findElement(By.linkText("ICIX")).click();
    Thread.sleep(3000);
    // TP Group 1
    TPO.create_tpGroup(driver, Group);
    Thread.sleep(8000);
    driver.findElement(By.linkText(Group)).click();
    Thread.sleep(8000);
    // set requirements 1
    driver.findElement(By.linkText("Set Requirements")).click();
    Thread.sleep(3000);
    driver.switchTo().frame(driver.findElement(By.id("vfFrameId")));
    Thread.sleep(3000);[please see the image][1]

I m getting mention error while its cliking on the "group" link as mentioned in code. Sometimes code working perfectly and sometimes it not

somebody please do the needful. Thanks a ton

mercredi 27 juillet 2016

How to Get IP Address of machine running tests (Selenium)

can anybody help me to find a way to store the IP address of the actual remote selenium node that is running the test in selenium ?

Android Espresso tests with rest api

I am currently testing my app's UI with Espresso, and have run into a few problems. My app requires a user to be logged in to use it, and then after logging in, in my apps onCreate I load a list with data that is retrieved from an api call to my server. How can i manually add this data(JSON) into my RecyclerView in my Espresso tests this way the app has data to work with during the testing.

Monitoring SMP with Web Inject

I built my web inject testcases.xml. I want to monitoring a Nagios events. Is it possible in system management portal (SMP) that one test case (check) is performed for multiple servers?

Watir - Find elements using partial text

Is there a way to find an element by just text it contains?

Given:

<div>foobar</div> `browser.div(text: contains('foo')).present?
# => true'

Can automated test scripts be used across multiple apps?

I'm fairly new to automated testing and I was wondering if you can take a group of the same automated scripts and run them across multiple apps? Or would they have to be modified every time to change object names, etc.?

how to get all elements of repeater under repeater

<item id="item-1" class="item ng-scope" ng-repeat="incident in $ctrl.allIncidents track by incident.dg_guid"><div role="tablist" class="panel-group" ng-transclude="">
    <div class="panel ng-scope ng-isolate-scope panel-default panel-open" ng-class="panelClass || 'panel-default'" is-open="$ctrl.isExpanded" style="">

  <div id="accordiongroup-1970-6335-panel" aria-labelledby="accordiongroup-1970-6335-tab" aria-hidden="false" role="tabpanel" class="panel-collapse in collapse" uib-collapse="
    <!-- ngIf: $ctrl.showTextArea -->
    <div>

            <!-- ngRepeat: event in $ctrl.timeline.filterBy track by $index --><div class="incident-details__description-text flex-space-between ng-scope" ng-repeat="event in $ctrl.timeline.filterBy track by $index">
                <div>
                    <!-- ngRepeat: time in event.date track by $index --><div class="timeline__time__container ng-scope timeline__container-first" ng-repeat="time in event.date track by $index" ng-class="{'timeline__container-first': $first}">
                        <span class="timeline__time ng-binding">8:39 PM</span><br>
                    </div><!-- end ngRepeat: time in event.date track by $index --><div class="timeline__time__container ng-scope" ng-repeat="time in event.date track by $index" ng-class="{'timeline__container-first': $first}">
                        <span class="timeline__time ng-binding">07/26/16</span><br>
                    </div><!-- end ngRepeat: time in event.date track by $index -->
                </div>                
                </div>
            </div><!-- end ngRepeat: event in $ctrl.timeline.filterBy track by $index --><div class="incident-details__description-text flex-space-between ng-scope" ng-repeat="event in $ctrl.timeline.filterBy track by $index">
                <div>
                    <!-- ngRepeat: time in event.date track by $index --><div class="timeline__time__container ng-scope timeline__container-first" ng-repeat="time in event.date track by $index" ng-class="{'timeline__container-first': $first}">
                        <span class="timeline__time ng-binding">7:08 PM</span><br>
                    </div><!-- end ngRepeat: time in event.date track by $index --><div class="timeline__time__container ng-scope" ng-repeat="time in event.date track by $index" ng-class="{'timeline__container-first': $first}">
                        <span class="timeline__time ng-binding">07/25/16</span><br>
                    </div><!-- end ngRepeat: time in event.date track by $index -->
                </div>

I am trying to get the timings of timeline__time

this.IncList = element.all(by.repeater('incident in $ctrl.allIncidents track by incident.dg_guid'));
this.FirtstIncTimeLine = this.IncList.get(0).element.all(by.repeater('event in $ctrl.timeline.filterBy track by $index'));
this.FirtstIncTopTimeLine = this.FirtstIncTimeLine.first();
this.FirtstIncTopTimeLineTime = this.FirtstIncTopTimeLine.element.all(by.css('span.timeline__time'));

I am getting following error:

Error: TypeError: this.IncList.get(...).element.all is not a function

How can I get all elements of repeater under a Repeater?

Automatic testing of user input in Drupal 8

I am using Drupal 8 and I am getting used to entities etc. The aim is to have a user input some Java code(a question) and another user to input the answer and I need to find a way of combining and testing the combination of these. For example the question could be a java class with some methods but one method hasn't been completed. The other person would have to create code for the method. Is there a way I can link an IDE to Drupal in order to combine these pieces of code automatically and test them in a main method to see if they run? Or is there a more simple way of doing it? I am quite new to all of this so apologies if this question is a bit rough but any advice would be welcome!

How can I test this Node.js module?

I have the following Node module which I would like to test:

'use strict';

var queueClientService = require('shared-services/lib/queueClient');
var Result = require('shared-services/lib/models/result');

module.exports.start = function() {
    var exchangeName = 'retuls';
    var exchangeType = 'fanout';
    var queueName = 'result.database';
    var options = {};

    queueClientService.consume(exchangeName, exchangeType, queueName, options, function(channel, message) {
        try {
            var data = JSON.parse(message.content.toString());
        }
        catch (error) {
            // Unparsable data; acknowledge the message and skip.
            return channel.ack(message);
        }

        if (data._id) {
            // If the incoming data an _id value, then it is already
            // saved to the database, so ignore it.
            return channel.ack(message);
        }

        // Use the data model directly to create the document.
        Result.create(data, function(error) {
            // Acknowledge the message.
            channel.ack(message);
        });
    });
};

With this module, when the start() method is called, it connects to a RabbitMQ service (via queueClientService) and listens on a channel for incoming messages. the last parameter to queueClientService.consume() is a callback to be called when a new message arrives in the queue. I would like to test that this callback does what I expect (i.e., Creates a "result" document).

What things will I need to do in order to successfully test this module? Here are some ideas I have so far:

  1. Mock queueClientService.
  2. Mock Result (which is a Mongoose data model).
  3. Somehow make require('shared-services/lib/queueClient') return the queueClientService mock.
  4. Somehow make require('shared-services/lib/models/result') return the Result mock.
  5. Load the module and call start().
  6. expect() that Result attempts creation of a MongoDB document OR expect() that Result.create() is .calledOnce.

How to debug on console with Hapi.js Lab test framework?

Mocha has the option to run tests with mocha debug, just like node debug, allowing debug within a REPL console.

How can I do REPL debug with Hapi Lab?

Aurelia. Testing. TypeError: config.addPipelineStep is not a function

I use default Aurelia's sceleton-esnext updated to last version . I added this line to App ( Example from doc. Customizing the Navigation Pipeline)

config.addPipelineStep('authorize', AuthorizeStep);

After this I catch error running 'gulp test'

Chrome 52.0.2743 (Linux 0.0.0) the App module contains a router property FAILED
TypeError: config.addPipelineStep is not a function

Test

  it('contains a router property', () => {
    expect(sut.router).toBeDefined();
  });

Test is going well without line.

Failed to get the file for deployment item while run test case in MTM

We deploy xml file in the code with below statement:

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\Scripts\SmokeTestSuite2016Q1\TestData\RPSmokeTestData.xml", "SM_Test_012",DataAccessMethod.Sequential),DeploymentItem("RPSmokeTestData.xml"), TestMethod]

In local its running fine, but even though while run we getting a warning as below:

Test Run deployment issue: Failed to get the file for deployment item 'RPSmokeTestData.xml': System.IO.FileNotFoundException: Could not find file 'D:\Automation\xxx\bin\Debug\RPSmokeTestData.xml'.

Warning: Test Run deployment issue: Failed to get the file for deployment item 'RPSmokeTestData.xml' specified by the test 'xxx.Scripts.SmokeTestSuite2016Q1.SmokeTest.RPSmokeTestUITest.SM_Test_012': System.IO.FileNotFoundException: Could not find file 'D:\Automation\RPSmokeTestData.xml'.

Warning: Test Run deployment issue: The assembly or module 'Microsoft.Practices.ServiceLocation' directly or indirectly referenced by the test container 'd:\automation\xxx\bin\debug\xxx.dll' was not found.

But the test runs successful.

Now we check-in the code to TFS server which we maintain in different environment and queue a build.

After complete build we try to run the test from MTM from local machine where both test controller and agent running locally.

  1. The test case without xml file is running successfully but if we try to run a test case which required test data from xml file we getting the following error.

TestOutcome 'Warning'; Message 'Warning: Test Run deployment issue:

Failed to get the file for deployment item 'RPSmokeTestData.xml' specified by the test

'demo.SmokeTestSuite2016Q1.SmokeTest.SmokeTestUITest2016Q1.SM_Test_004': System.IO.FileNotFoundException: Could not find file

'C:\Users\deepan\AppData\Local\VSEQT\QTController\RPSmokeTestData.xml'.'."

Testing NoClassDefFoundError rx/Observable$OnSubscribe

I'm trying to learn how to use Robolectric to do test on my app, but I'm facing the next problem.

ERROR

Downloading: org/robolectric/android-all/4.1.2_r1-robolectric-0/android-all-4.1.2_r1-robolectric-0.jar from repository sonatype at http://ift.tt/1266f41
Transferring 30702K from sonatype
Downloading: org/robolectric/shadows-core-v16/3.1.1/shadows-core-v16-3.1.1.jar from repository sonatype at http://ift.tt/1266f41
Transferring 2581K from sonatype

java.lang.NoClassDefFoundError: rx/Observable$OnSubscribe

    at com.testingex.timeexpensestool.TETApplication.onCreate(TETApplication.java:30)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:152)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:237)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:174)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:63)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:140)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: rx.Observable$OnSubscribe
    at org.robolectric.internal.bytecode.InstrumentingClassLoader.getByteCode(InstrumentingClassLoader.java:192)
    at org.robolectric.internal.bytecode.InstrumentingClassLoader.findClass(InstrumentingClassLoader.java:147)
    at org.robolectric.internal.bytecode.InstrumentingClassLoader.loadClass(InstrumentingClassLoader.java:122)
    ... 21 more


java.util.ServiceConfigurationError: org.robolectric.internal.ShadowProvider: Provider org.robolectric.shadows.support.v4.Shadows not a subtype

    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at org.robolectric.internal.bytecode.InstrumentationConfiguration$Builder.build(InstrumentationConfiguration.java:151)
    at org.robolectric.RobolectricTestRunner.createClassLoaderConfig(RobolectricTestRunner.java:118)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:172)
    at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:63)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:140)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

My test is the next:

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, application = TETApplication.class, sdk = Build.VERSION_CODES.JELLY_BEAN)
public class LoginActivityTest {

    private LoginActivity activity;

    @Before
    public void setUp() throws Exception {
        activity = Robolectric.buildActivity( LoginActivity.class )
                .create()
                .resume()
                .get();
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void testLogin() throws Exception {

    }

    @Test
    public void testEmail() throws Exception {

        activity = Robolectric.setupActivity(LoginActivity.class);

        EditText etEmail = (EditText) activity.findViewById(R.id.login_email);
        ActionProcessButton apbtLogin = (ActionProcessButton) activity.findViewById(R.id.btn_login);

        etEmail.setText("maol@thisismymail.com");
        apbtLogin.performClick();
        assertNotNull(etEmail.getText());
    }
}

The custom application class, is:

public class TETApplication extends MultiDexApplication {

    private static TETApplication singleton;

    public static TETApplication getInstance() {
        return singleton;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        singleton = this;

        Hawk.init(this)
                .setEncryptionMethod(HawkBuilder.EncryptionMethod.MEDIUM)
                .setStorage(HawkBuilder.newSqliteStorage(this))
                .setLogLevel(LogLevel.FULL)
                .build();

        Dexter.initialize(getApplicationContext());
    }

    @Override
    protected void attachBaseContext(Context base) {
        try {
            super.attachBaseContext(base);
            MultiDex.install(this);
        } catch (Exception e) {
            String vmName = System.getProperty("java.vm.name");
            if (!vmName.startsWith("Java")) {
                throw e;
            }
        }
    }
}

I'm using a library to store variables called "Hawk", I don't know if this is the problem.

Thanks

Logging the time for each test (and/or testSuite) with scala test

I'm using scala test for my tests, and some time ago the builds started to fail sometimes because some (new, probably) test takes more than the limit allowed by the CI.

At first sight no test should take more than the timeout (10 minutes btw), and by the CI output it not easy to see which test is taking so much time (or how much time every test takes)

I can put simple println-based statements to print the current hour at the beginning/end of each test, but I was wondering if scala test provides some builtin feature for that?

If no, does any other scala test framework/library does?

Android what means "refactoring across test artifacts"

I am currently looking the video Android Testing (Android Dev Summit 2015) . It is mentionned the possibility to refactor across test artifact. At 16:20 in the video, Jorge Alcérreca says "...you will be able to refactor across Test Artifacts, if you know what I am talking about, you know this is huge"...

Well, I don't know what he is talking about, can someone give me some clue?

Protractor, mocking API calls

I am following this tutorial. http://ift.tt/1s1DFCs

so in my mock.js

exports.signin_request = function(){
    var expected_response = ('1 - noor.alhabbal@gmail.com')
    angular.module('httpBackendMock', ['userManagement', 'ngMockE2E'])
        .run(function ($httpBackend) {
            $httpBackend.whenGET('http://ift.tt/2agiV6q').respond(function(){
                return [200, expected_response];
            });
            // $httpBackend.whenGET(/.*/).passThrough();
    });
}

and in my function

it('should check if the api is working and returns correct login value',function()
    {
        browser.addMockModule('httpBackendMock', mockModule.signin_request);  

        expect (mockModule.signin_request).toEqual[200,'user@gmail.com']
    })

the API returns the email if it's valid or the word error if it's not. My expect statement is wrong. How can I fix it to make sure that what I got back is "user@gmail.com"

How to track errors when distributing Android Application to Alpha Testers?

I recently released an application for some users to use my newly made Android Application. However, they are having trouble when they perform the Facebook Login feature that I have made.

It seems to work fine on my phone, but on other phones it seems to crash. I would like to know what is causing the application to crash so I can further debug this. Is there anywhere or anything that I can use to debug this problem further?

I have looked at both the Facebook Developer Console and Google Play Developer Console and neither seem to show or point me to where my error is. If anyone could help that would be great. Thanks!

mardi 26 juillet 2016

MS Access Performance Testing

I am working on a application which has MS Access as frontend and SQL server as it backend. I am required to do performance testing of this application for load and overall system performance.

It would really healp if someone could suggest some tools to automate this and do the testing in a more effective manner.

RSpec with Capybara, rerun an entire feature if a scenario fails

I’m currently using RSpec and Capybara to test a website. Say I have a feature file such as this.

Feature: A simple feature
  Scenario: name monster
    Given there is a monster called "John Smith"
    Then it should be called "John Smith"

  Scenario: change monster name
    Given there is a monster called "John Smith"
    When I change its name to ""
    Then it should be nameless

  Scenario: name monster john
    Given there is a monster called John
    Then it should be called "John"

I would like to run this feature file so that if an individual scenario fails then the entire feature file will be rerun and if it fails again the test will fail as normal. Otherwise, if on the second run through it passes it should continue as normal.

So in accordance with the above feature, if the scenario "name monster john" fails then the file should be run from the beginning, starting with the first scenario, "name monster".

I have tried using the code below, which will rerun only a scenario (not the all the scenarios) if it fails up to three times at which point it will permanently fail. What I am trying to do however is rerun the entire feature file from the beginning.

require 'rspec/core'
require 'rspec/flaky/version'
require 'rspec_ext/rspec_ext'

 module RSpec
  class Flaky
    def self.apply
      RSpec.configure do |conf|
        conf.add_setting :verbose_retry_flaky_example, default: false
        conf.add_setting :flaky_retry_count, default: 1
        conf.add_setting :flaky_sleep_interval, default: 0

        # from rspec/rspec-core
        # context.example is deprecated, but RSpec.current_example is not
        # available until RSpec 3.0.
        fetch_current_example = RSpec.respond_to?(:current_example) ?
            proc { RSpec.current_example } : proc { |context| context.example    }

        conf.around :all, type: :feature do |example|
          retry_count = RSpec.configuration.flaky_retry_count
          sleep_interval = RSpec.configuration.flaky_sleep_interval

          # from rspec/rspec-core
          current_example = fetch_current_example.call(self)

          retry_count.times do |r_count|
            if RSpec.configuration.verbose_retry_flaky_example && r_count > 0
              msg = "\n Test failed! Retrying...This is retry: #{r_count}
                    \n Failed at:  #{example.location}"
              RSpec.configuration.reporter.message msg
            end

            current_example.clear_exception
            example.run

            break if current_example.exception.nil?

            sleep sleep_interval if sleep_interval > 0
          end

        end # conf.around
      end # RSpec.configure
    end # def self.apply
  end # class Flaky
end # module RSpec

RSpec::Flaky.apply

Does RSpec have any way to rerun an entire feature or is this not possible?

Firebase - Can't run tests against standalone test project

I'm investigating a cloud-based solution for our UIAutomator 2.0 testing needs, and I'm having quite a few issues with uploading APKs for our test project.

We have a stand-alone test project that exists separately from the main Android application project. The package for the project is in the format com.company.project and the package for the test project is com.company.project.test.

1) If I attempt to upload a test APK that has all the tests in androidTest (and the gradle uses androidTestCompile for dependencies), Firebase console complains that:

"Unable to find instrumentation package for com.company.project.test"

This is likely because our test project is standalone, and the tests actually live under com.company.project.test.test.

2) On the other hand, if I change the location of tests to java main folder in the project and change androidTestCompile to compile for the gradle dependencies, when I attempt to upload the test APK Firebase console complains again:

"We experienced an error while validating your APK. Please verify the APK is correct and upload again."

I can't get a single test running since I'm blocked both ways.

Anyone else attempt to use Firebase Test Lab with a similar project hierarchy? Help!

How to approve Paypal adaptive preapproval payment from code to be used in tests

I am looking into cover our PayPal integration with integration tests to verify all payment flows work correct.

We are currently supporting both Stripe and Paypal as payment providers. With Stripe, its possible to generate payment tokens etc. through their api and thereby "simulate" an end to end payment scenario.

I am looking into doing the same with Paypal adaptive payments (preapproval flow), but I can't seem to find any resources for "approving" my preapproval token through their API.

Even if I assign a sender to the preapproval request where I have permissions to make charges on their behalf (3rd party "AUTH_CAPTURE").

Anyone that can help point me in the right direction for fully automated testing of paypal payment flows. Having to manually log in and approve every key for every test is not a scalable solution :(

React enzyme testing, Cannot read property 'have' of undefined

I'm writing a test using Enzyme for React.

My test is extremely straightforward:

import OffCanvasMenu from '../index';
import { Link } from 'react-router';

import expect from 'expect';
import { shallow, mount } from 'enzyme';
import sinon from 'sinon';
import React from 'react';

describe('<OffCanvasMenu />', () => {
  it('contains 5 <Link /> components', () => {
    const wrapper = shallow(<OffCanvasMenu />);
    expect(wrapper.find(<Link />)).to.have.length(5);
  });
});

This code is basically taken directly from airbnb/enzyme docs, but returns the error:

FAILED TESTS:
  <OffCanvasMenu />
    ✖ contains 5 <Link /> components
      Chrome 52.0.2743 (Mac OS X 10.11.6)
    TypeError: Cannot read property 'have' of undefined

I'm a little unclear on what I'm doing differently from the docs. Any guidance greatly appreciated.

Django Redirect Status Code Error

I'm testing a Django app. When the user logs in, I redirect him to a graphs page. To test, I write

response = TestCase.client.post('app/login', {credentials}, follow=True)
TestCase.assertRedirects(response, 'app/graphs')

which returns

AssertionError: False is not true : 
Response didn't redirect as expected: Response code was 200 (expected 302).


Reasonable enough. The docs say assertRedirects has a status_code parameter. Then calling

TestCase.assertRedirects(response, 'app/graphs', status_code=200)

returns

AssertionError: False is not true : 
Response didn't redirect as expected: Response code was 200 (expected 200).

What's going on?

how can i get the ServerTrustPolicy.certificatesInBundle of alamofire in Unit Testing case in swift?

i use alamofire framework with a project testing.

In a simple project, i can get the list of certificat server by calling ServerTrustPolicy.certificatesInBundle of alamofire.

But how can i do that in project testing ? the ServerTrustPolicy.certificatesInBundle always return me 0 certificat.

Use debug assets in releseUnitTest instead of the release app assets

I run my unit tests with robolectric. For some test I added json files in the debug assest folder and get them via: RuntimeEnvironment.application.getResources().getAssets().open(filename);

In the debugUnitTest I have access to the the debugAssests, but if I run my releaseUnitTest I don't.

How can I tell the releaseUnitTest to get the assets from the debug folder? Or where would you save the json files to use them in the unit tests?

Build many dockerfiles on jenkins project

I have some task:

I have github repostiroy with folder "docker" and in this folder have many sub-folders with names (app1, app2, app3, etc.) with only Dockerfile in subfolder.

Sometimes i add new subfolder with name app50 and i want to Jenkins build automatically this new dockerfile and if all ok push new images to private docker registry.

How I can automate to select sub-folder, enter to him and run docker build ? with cutsom tag and name.

For example i upload new folder "app70-1.2.3" with Dockerfile. Jenkins need enter to folder "docker/app70-1.2.3" and run "docker build -t app70:1.2.3 ."

Share Test Helpers across repos using bower

We have a couple repositories we manage with bower and in one, Core, we have code that has a bunch of testing data. In another, UI, we want to use that code for testing purposes. In order for users of Core not to get our tests, we have bower ignore that directory, which prevents UI from pulling it down. Is there a way for UI to use bower get the code with testing data without others as well? Or should we just allow others to get the testing data?

Different ways to test Mobile Web application in desktop

I am a tester who will be testing a web application that will be accessed by the users on mobile using a browser. I would like to know what are the different ways I can test this application for mobile using my desktop. What tools can be used to test mobile web apps.

Thank you Sandy

How can this element button be clicked using protractor?

I'm trying to select this button using protractor:

<button tabindex="-1" type="button" class="btn btn-default pull-left" ng-click="$arrowAction(-1, 0)">

 <i class="glyphicon glyphicon-chevron-up">
 </i>

</button>

the only unique element in this is ng-click="$arrowAction(-1, 0)"

Nothing I have tried works:

element(by.css("//button[@ng-click='$arrowAction(-1, 0)']")).click();

Symfony2 functional test and session persistance

Here is my problem, I add session variable from functional test controller and they don't popup on action targeted by test.

I made a login method and used cookbook advice to log in. I tuned it a bit to allow 2 accounts login : admin and superadmin

/**
     * @param $account string the account to log in with (authorized : superadmin and admin)
     */
    protected function logIn($account)
    {
        $this->session = $this->container->get('session');
        // Cookbook try
        // $this->session = new Session(new MockFileSessionStorage());
        $user = $this->em->getRepository('LCHUserBundle:User')->findOneByUsername($account);
        $firewall = 'admin_area';

        switch($account) {
            case self::SUPER_ADMIN_LOGIN:
                $token = new UsernamePasswordToken($user, $account, $firewall, array('ROLE_SUPER_ADMIN'));
                $this->client->setServerParameter("SERVER_NAME", SiteControllerTest::ROOT_SITE);
                $this->client->setServerParameter("HTTP_HOST", SiteControllerTest::ROOT_SITE);
                break;
            case self::ADMIN_LOGIN:
                $token = new UsernamePasswordToken($user, $account, $firewall, array('ROLE_ADMIN'));

                // Session var I wish to have on my controller action tested
                $this->session->set('currentSite', $this->em->getRepository('LCHMultisiteBundle:Site')->find(1));
                $this->session->save();

                // Use to force server canonical name for admin test
                $this->client->setServerParameter("SERVER_NAME", SiteControllerTest::ROOT_SITE);
                $this->client->setServerParameter("HTTP_HOST", SiteControllerTest::TEST_SITE);
                break;
            default:
                throw new UsernameNotFoundException('Username provided doesn\'t match any authorized account');
        }
        // Save user in session
        $this->session->set('_security_'.$firewall, serialize($token));
        $this->session->set('user', $user);
        $this->session->save();
        // $this->container->set('session', $this->session);

        $cookie = new Cookie($this->session->getName(), $this->session->getId());
        $this->client->getCookieJar()->set($cookie);

My setUp() method does this :

/**
     * {@inheritDoc}
     */
    protected function setUp()
    {
        // Initiates client
        $this->client = static::createClient();

        $this->container = $this->client->getContainer();
        $this->application = new Application($this->client->getKernel());
        $this->application->setAutoExit(false);
        $this->translator = $this->container->get('translator');
        $this->em = $this->container
            ->get('doctrine')
            ->getManager();
    }

You can see that I set session vars for authentication. They appear correctly when I dump session var from tested action, but if I add my currentSite session var, it seems not persisted. As I use the test container provided by client, it should be passed on shouldn't it?

PS : I also overrided Client class, according to this other question.

I found numerous posts on topic but none provide any working solution (this one, this one or that one). I also found this cookbook article.